+ 2
help with sum of elements of an array in js
I'm in the js arrays lesson in practice 39.2 and I don't know how to add the elements of an array without knowing how many they are, it is the problem of adding the points of levels of a game. someone who has solved it to guide me please.
2 Answers
+ 3
const sum = arr.reduce((s,v)=>s+v);
+ 2
Thanks