Intermediate Algorithm Scripting - Sum All Numbers in a Range

Good morning, having a little trouble understanding the difference between arr[i], [i], and i when for example saying
sum += arr[i]
sum += [i]
sum += i
Your code so far

function sumAll(arr) {
      sum += i

sumAll([1, 4]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/107.0.1418.42

Challenge: Intermediate Algorithm Scripting - Sum All Numbers in a Range

Link to the challenge:

Perfect! Thank you, sorry i was elbow deep in another challenge x) That really helped though

Yeah i also avoided putting the rest of the solution/for loop in the post so it wouldn’t get taken down

There are at least 4 different solutions in the hint section for this exercise, no need to worry about that.
Everyone who is doing this knows that they are learning for themselves and that there is nothing to gain by copying a solution without trying to solve it :slightly_smiling_face:

Absolutely. When i do have to go and look at the solution, i don’t feel right moving on if i don’t understand why everything in the solution is there and how it works. There is no use moving on if we don’t learn anything from it haha

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.