Guest User

Untitled

a guest
Feb 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. function sumItems(array) {
  2. // Sum all the numbers in the array
  3. let sum = 0;
  4. array.forEach((item) => {
  5. if (Array.isArray(item)) {
  6. sum += sumItems(item);
  7. } else {
  8. sum += item;
  9. }
  10. })
  11. return sum;
  12. }
Add Comment
Please, Sign In to add comment