javascript do while loop

1
I think the idea there is not to repeat yourself. You're calling prompt twice. You can overcome this by declaring the variable that will be defined in the loop later. Also, make sure you terminate your statements in JS with semicolons. var secret; do { secret = prompt("What is the secret password?"); } while ( secret !== "sesame" ); document.write("You know the secret password. Welcome.");

Upload: sampath-reddy

Post on 14-Apr-2016

215 views

Category:

Documents


0 download

DESCRIPTION

Javascript do while loop

TRANSCRIPT

Page 1: Javascript Do While Loop

I think the idea there is not to repeat yourself. You're calling prompt twice. You can overcome this by declaring the variable that will be defined in the loop later.

Also, make sure you terminate your statements in JS with semicolons.

var secret;

do { secret = prompt("What is the secret password?");

} while ( secret !== "sesame" );

document.write("You know the secret password. Welcome.");