3 ms·
So, if I want get the sum of an array of numbers, the only option is to use recursion or a reduce function? Is there a way to accomplish this using a for loop w
by thalesmello 12y ago
So, if I want get the sum of an array of numbers, the only option is to use recursion or a reduce function? Is there a way to accomplish this using a for loop while sticking to let keywords?
- Skalman 12y agoPerhaps you didn't catch that basically the difference between let and var is that let is block-scoped, while var is function-scoped? let result = 0; for (let i = 0; i < arr.length; i++) { result += arr[i]; }