Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sumItems(array) {
- // Sum all the numbers in the array
- let sum = 0;
- array.forEach((item) => {
- if (Array.isArray(item)) {
- sum += sumItems(item);
- } else {
- sum += item;
- }
- })
- return sum;
- }
Add Comment
Please, Sign In to add comment