JS-Dev-101 practice question 2 of 25

A developer is required to write a function that calculates the sum of elements in an array but is getting undefined every time the code is executed…

Choose your answer, then check it against the explanation.

A developer is required to write a function that calculates the sum of elements in an array but is getting undefined every time the code is executed. The developer needs to find what is missing in the code below. 01 const sumFunction = arr => { 02 return arr.reduce((result, current) => { 03 // 04 result += current; 05 // 06 }, 10); 07 }; Which line replacement makes the code work as expected?
Answer options
Question 2 of 25

Keep practicing

Take the free JS-Dev-101 practice test

Ten exam-style questions with answers and explanations, plus the exam facts and study guides.

Start the free practice test

More questions

Other JS-Dev-101 practice questions

Scroll to Top