// 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);JavaScript Sum of Array Elements
javascript
Related Posts
More content you might like
Code
javascript
Calculating the Average of an Array in JavaScript
No preview available for this content.
Jan 26, 2024
Read More Code
javascript
Sorting an Array in JavaScript
No preview available for this content.
Jan 26, 2024
Read MoreDiscussion 0
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!