Tell us what’s happening:
Describe your issue in detail here.
**Your code so far**
// Setup
var myArray = [];
var i = 0;
// Only change code below this line
while(i < 6) {
myArray.push(i);
i++;
// should return 0,1,2,3,4,5
// it return 1,2,3,4,5,6
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0
Challenge: Basic JavaScript - Iterate with JavaScript While Loops
var myArray = [];
var i = 0;
// Only change code below this line
while(i < 6) {
myArray.push(i);
i++;
// should return 0,1,2,3,4,5
// it return 1,2,3,4,5,6
}
console.log(myArray);//[ 0, 1, 2, 3, 4, 5 ]
You might have noticed that methods like insert , remove or sort that only modify the list have no return value printed – they return the default None . 1 This is a design principle for all mutable data structures in Python.
Not a Python guy BTW but I assume it applies to append as well,