0
How to add an array
If the user inputs an array, starting by the length of it: I.e. Input: 3, 4, 5, 6 [4,5,6] How can I code in order to get the sum of the contents of the array? I.e Input : 4,5,5,6,0 Output: 16
2 Réponses
+ 2
sum = array.reduce((r,v) => r+v,0);
assuming the array contains numbers, not strings ^^