Tech Junkie Blog - Real World Tutorials, Happy Coding!: JavaScript Basics : do/while Loop

Friday, April 21, 2017

JavaScript Basics : do/while Loop

The do/while loop is similar to the while loop.  The difference is that the first the loop expression is tested after the do statement block is executed at least once.  For example let's use our countdown example again.

If we have the code below the countdown displays the same results as the output.  However, the first iteration is performed without a evaluation of the expression.  It's not until the countdown is 9 that the while part of the loop kicks in.

var countdown = 10;

do {
while(countdown > 0)

console.log("Happy New Year!");

1 comment:

  1. Accomplished designers have to work to design a logo and this takes work. To design a logo, you need to invest time and effort. It is not equivalent to just playing on the computer for a few hours.


Search This Blog