Basic JavaScript - Iterate with JavaScript While Loops

Tell us what’s happening:
Describe your issue in detail here .I have to be honest, when i am struggling with a code ,after numerous attempts i check the video or the hints and find it quite misleading when the test says to “only change the code below this line” then all the solutions have changed the "const myArray to " “var myArray” and then when following the solutions once i understand it the code that replicates the solution doesn’t pass. what am i missing with my code here, i know its only something small but i am stuck.

Your code so far

// Setup
var myArray = [];

// Only change code below this line
let i=0
while ( i < 5) {

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.125 Safari/537.36

Challenge: Basic JavaScript - Iterate with JavaScript While Loops

Link to the challenge:

Your code is essentially backwards to what is required.
The instructions are to push values 5 to 0 (inclusive) to the array.
Your code is pushing values 0 to 4.

It’s helpful to console.log your array so you can see what your while loop is actually doing. Include a console.log at the end of your code.

Although it hasn’t been deprecated, var is generally not used much anymore, as it has been superseded by let and const. So, whilst it makes no difference to the successful execution of your code, I’d stick with const in this case.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.