The "while" bit do/while loops not working?


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-ASGIv/2/4?curriculum_id=506324b3a7dffd00020bf661

Hello,

On the review section of the exercise i have typed out codes for all 3 loops (for,while and do/while).

I have managed to get my For Loop and While Loop working, but i am struggling with the do/while loop.

My original while loop brings up the result:

This is while loop 0
This is while loop 1
This is while loop 2

I wanted my do/while loop to do the same thing except have "This is the 'do' bit" above the other while loop.

However i only seem to get

"This is the 'do' bit
do/while loop 0
3"

Something similar happened during the do/while loop exercise too.

My understanding is that the 'do' command should write "this is the do bit" then the while command should simply act like my other 'while loop' and print out "This is while loop" 0 etc

Am i doing something wrong or have i misunderstood "do/while" loops?

Thanks


var count = 0;

while(count < 3) {
    console.log("This is while loop "+ count);
    count++;
};

var name = 0
do {
    console.log("This is the 'do' bit");
} while(count < 3) {
    console.log("do/while loop " + name);
    count++;
};


#2

Have a look at this: