} while (i<5)
So, within this code, I just have one simple question. When I do
console.log(i, myArray), I get two things in my console: the numbers 11, and 10. I understand where the 11 came from, as it is
i incremented (occurs because of the do statement, which runs the code first, and checks later if it fits the parameter), but however, where does the 10 appear from?
If you are referring to this output:
It is because you are logging
myArray to the console, as well. You push
i (when it is equal to
10) to the array, then log it to the console.
I hope this helps
sorry, there was a line missing at the top:
myArray=. So what you’re saying is that the array is just
i, but why?
do...while condition is
i < 5. However, you already start with
i > 5 so the itteration will only run once. Therefore, this line only gets executed once:
console.log(i, myArray) logs both
i (equal to
myArray ( consisting of
Perhaps, to help you understand, replace your first line
let myArray = 
let myArray = ;
Hope this helps
So, it pushes
10 into the array, put doesn’t increase it. OHHHHHHH.