11. Review - do while loop has duplicate response


#1

I created this do while loop below but it returned a number twice. How come?

Here is the do while loop:

x = 10;
do {
console.log(x);
x--;
} while (x > 5)

And it returned:

10
9
8
7
6
6

**edit - it seems like it may have to do other codes written above/below it. I just tried putting a code below this one and it gave me double of the last response but the previous code (above) no longer has both 6. Anyone know why this happens or if it should happen? How do I write the code so the last number only show up once. It seems odd that the code repeats the last number twice.

This is the code I put below to test it:

x = 7;
do {
console.log(x);
x++;
} while (x < 10)

and it returned:

7
8
9
9


#2

@goldiefish,

It is the Javascript interpreter which is running in this course-environment,
it display's the last non-displayed action...

You will also encounter this, when you are doing a return-statement
as last action...
You could counter this by using a
console.log( " " ); as last statement....

In some sections of this course, the course-checker Display's data
this you could then identify by placing to EXTRA code-line's:
console.log( "== My End ==" );
console.log( "== All that is displayed now, is the course-checker ==" );

Try it with

x = 10;
do {
     console.log(x);
     x--;
} while (x > 5)
console.log( "== My End ==" );
console.log( "== All that is displayed now, is the course-checker ==" );