I suddenly feel lost. I thought I had a handle on this, but I guess not.

Can anyone spot my mistake? I feel like I have made a logic mistake somewhere, but can't figure it out.

I'm gett this wrror:
Oops, try again. It looks like one of your loops isn't quite right. Check the Hint if you need help!

var i = 0
var k = false 

for (i = 1; i < 5; i ++) {

do {
    console.log("Wait, how many?");
} while(i === 100);

var j = 0;

while(i === 100) {
    console.log("That's too many.");
    j = false;

Thanks in advance. I really appreciate this community.


You have a few things that are wrong, but for the most part, you seem to grasp some of these loops. Here are some of the things I'll point out:

var i = 0

Here, you set the variable i equal to 0, but then at the beginning of your for loop, you set it equal to 1:

for (i = 1;

This isn't causing any errors, but it will tell you a little bit about what's going on.

Additionally, you set the variable k to false, but you never reference k once in the program besides when you initialize it. Just wondering what your'e doing with it.

Where you're actually having an error is in your while loop. Can you explain to me what you think each part of the while loop is doing? And how it differs from one of the example while loops from an earlier lesson, like say, this one:

var understand = true;

while(understand == true){
	console.log("I'm learning while loops!");
	understand = false;

from here?


It takes careful logic to use an identity in a while conditional. Much simpler to permit a whole range of true values, that once exceeded will be false.

In your above code, i is never equal to 100. For this exercise, since it is logging, better to stick with 10 or less as the upper limit.

while (i < 10)

Be sure to increment i inside the loop.

Your last loop is testing i and setting j. In this case, set j to true, then,

while (j) {
    // now toggle j


Thanks for the reply and for pointing out some of my errors. I'll respond to your questions as best I can:

  • There was not reason that I set var i = 0 globally and then for (i = 1; It was actually just random. I didn't think it mattered since one was global and one was local.

  • I intended to delete var k = false It was something I was trying while I was playing around with the code.

var j = 0;
while(i === 100) {
console.log("That's too many.");
j = false;

I really didn't know what to put into the while loop, so I was just attempting to have it print something and not be infinite.


Thank you for your reply.

I ended up doing this:

while(i) {
console.log("That's too many.");
i = false;


Hopefully you also closed the code block?


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