Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Exam Javascript Developer I Topic 1 Question 66 Discussion

Actual exam question for Salesforce's Javascript Developer I exam
Question #: 66
Topic #: 1
[All Javascript Developer I Questions]

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?

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Delisa
4 days ago
Wait, what? Undefined? That's a classic JavaScript conundrum. I'd say option D is the way to go, but who knows, maybe the developer just needs more coffee.
upvoted 0 times
...
Katina
7 days ago
But if we look at the code, it seems like line 04 needs to be fixed to update the result correctly.
upvoted 0 times
...
Lynna
8 days ago
Aha! I bet the problem is with the curly braces. They seem to be a bit out of place. Let me try option B and see if that fixes it.
upvoted 0 times
...
Marge
9 days ago
I disagree, I believe option D is the right one.
upvoted 0 times
...
Raul
9 days ago
Hmm, I think the issue is with the reduce function. The initial value should be passed as the second argument, not in the callback function.
upvoted 0 times
...
Katina
11 days ago
I think the correct option is B.
upvoted 0 times
...

Save Cancel