Medium
JavaScript Array Reduce: How to Sum Even Numbers Using Reduce Method
What will the following code output, and why?
1const nums = [1, 2, 3];2const result = nums.reduce((acc, curr) => {3 if (curr % 2 === 0) return acc + curr;4 return acc;5}, 0);67console.log(result);