0

Can someone explain to me how the output become that?

Var myArray = []; Var i = 10 do { myArray.push(i); i++ } while (i < 5) Console.log(i,myArray); Output= 11 [10]

28th Apr 2020, 3:29 PM
卓Hanson
卓Hanson - avatar
2 Réponses
+ 1
It pushed the 10 into array so it contains only one element that is [10] and do Loop runs once before checking the condition and since i>5 only 10 is stored in array,also i got incremented after pushing 10 so i is 11
28th Apr 2020, 3:35 PM
Abhay
Abhay - avatar
+ 1
Abhay now i got it,thx man😊😌
28th Apr 2020, 4:24 PM
卓Hanson
卓Hanson - avatar