CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

reduce to a Sum

JavaScript code walkthrough · Question 6
mediumArrays

Code

Read carefully. What does this print?
1const nums = [1, 2, 3, 4];
2const total = nums.reduce((acc, x) => acc + x, 0);
3console.log(total);

Your answer