ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 21 - Certified JavaScript Developer I discussion

Report
Export

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.

Const sumFunction = arr => {

Return arr.reduce((result, current) => {

//

Result += current;

//

), 10);

);Which option makes the code work as expected?

A.
Replace line 02 with return arr.map(( result, current) => (
Answers
A.
Replace line 02 with return arr.map(( result, current) => (
B.
Replace line 04 with result = result +current;
Answers
B.
Replace line 04 with result = result +current;
C.
Replace line 03 with if(arr.length == 0 ) ( return 0; )
Answers
C.
Replace line 03 with if(arr.length == 0 ) ( return 0; )
D.
Replace line 05 with return result;
Answers
D.
Replace line 05 with return result;
Suggested answer: D
asked 23/09/2024
Karsten Heimers
41 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first