Problem from HackerRank.
Easy problem but I got confused with the index of the array and its value. I was adding i
Β to my result variable and not ar[i]
.
1 2 3 4 5 6 7 8 9 |
function simpleArraySum(ar) { let result = 0; for (let i = 0; i < ar.length; i++) { result += ar[i]; }; return result; } |