0
I don't get it
Why the result is 17? (Arrays module 3 quiz, 2nd question) please help :(
1 Answer
+ 5
result = result + i, right?
so it's:
result = result + 0 // (result == 0 yet)
result = 0 + 1 // (result == 1)
result = 1 + 2 // (result == 3)
this time, if(i==3){
result += 10;
}
so instead of result getting the value of i (3), it is going to get + 10 to it's existing value. so result will be 13.
and the last time the loop runs (i == 4)
result += 4 (17).
i hope you understood it