sum element

EMBED

Sun Apr 16 2023 16:28:07 GMT+0000 (Coordinated Universal Time)

Saved by @sonalikhadake


/* Given an array of integers [3, 5, 2, 8, 1, 9], create a new array where each element is the sum of the current element and the next element in the original array. If there is no next element, the new array should contain the current element. */

https://jsfiddle.net/qf5et61m/