discussions icon indicating copy to clipboard operation
discussions copied to clipboard

Javascript exercise for-loop.

Open MarcoL10 opened this issue 2 years ago • 5 comments

I have a problem with the exercise for-loop with JavaScripting. I mean I got the right result but just I don't understand why the result is 45. Can someone gently explain it to me ? How total become 45 ? Thanks in advance

MarcoL10 avatar Apr 21 '22 19:04 MarcoL10

i have the same problem, what does it mean?

flicksuper avatar Apr 22 '22 21:04 flicksuper

I can’t do it, how do I do it?

Orevic64 avatar May 16 '22 15:05 Orevic64

same problem

Waden03 avatar May 31 '22 14:05 Waden03

Hello people, if you have the correct result, your codes are something like this:

let total = 0
let limit = 10

for(let i = 0; i < limit; i++){
  total = total + i
}       

console.log(total) 

for each repetition, the previous value of the variable i is added for i between 0 and 10 the result is: 0+1+2+3+4+5+6+7+8+9 = 45

mzgdev avatar Sep 10 '22 01:09 mzgdev

have no clue

Esme6969 avatar Nov 18 '22 20:11 Esme6969