do-while javascript code example
Example 1: do while javascript
var i = 0;
do {
text += "The number is " + i;
i++;
}
while (i < 5);
Example 2: javascript do while
var result = '';
var i = 0;
do {
i += 1;
result += i + ' ';
}
while (i > 0 && i < 5);
// Despite i == 0 this will still loop as it starts off without the test
console.log(result);