CJCoding With Joseph
← Back to Question List
JavaScript Code Walkthrough #6

reduce to a Sum

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