Just wanted to point out some issues with a lesson I am on:
I’m getting a 404 error while clicking the hint button for the “Iterate with Javascript Do…While Loops” Basic Javascript lesson.
Please find my solution below. My question is: is there a problem with using the .splice(i-10) code to create the solution? Happy for this to be used as a solution if there aren’t any issues from the more experienced community.
Thanks for your time.
Your code so far
// Setup
var myArray = [];
var i = 0;
// Only change code below this line.
do {
myArray.push(i);
i++;
myArray.splice(i-10);
}
while (i < 11);
console.log(myArray);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0.
Link to the challenge:
Can’t link yet. Not allowed.
Can you explain your logic in using that? What it is you want to do, what do you think it is doing…
The only thing you need to do is change the loop to a do…while, anything else is just extra resources taken for nothing.
You don’t need to change the initial var i = 10 or the comparison. Because even if i < 5 is false the do … while loop still execute once
It’s not exactly a problem, but don’t you think it would be more efficient, if you’d just initiate i with value of -10? It would save you 11 substraction operations at least