DeveloperBreeze

JavaScript Sum of Array Elements

javascript
// Array of numbers
const numbers = [1, 2, 3, 4, 5];

// Calculate the sum of array elements using the reduce method
const sum = numbers.reduce((acc, curr) => acc + curr, 0);

// Display the sum
console.log('Sum of Array Elements:', sum);

Continue Reading

Handpicked posts just for you — based on your current read.

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!