javascript
Published on January 26, 2024By DeveloperBreeze
// 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);
Comments
Please log in to leave a comment.