function prompt_if_else()

Define a variable which equals the text input by the user.
Prompt the user to input text.
Compare the user's input to conditions to be met.
Write the result of the comparison.

Carry On!

function prompt_if_else(){

//Define a variable which equals the text input by the user

var user_input = prompt("Enter a, b or c","lower case, please"); //prompt displays a dialog box

confirm("You entered "+user_input); //confirm with no option if user presses 'Cancel'

if(user_input == "a"){ //Beginning of the conditional. Did the user input 'a'?

document.write(user_input+":a<br />"); //Yes the user input 'a'. Now skip to end of conditional.

}else if(user_input == "b"){ //No the user did NOT input 'a'. Did the user input 'b'?

document.write(user_input+":b<br />"); //Yes the user input 'b'. Now skip to end of conditional.

}else if(user_input == "c"){ //No the user did NOT input 'b'. Did the user input 'c'?

document.write(user_input+":c<br />"); //Yes the user input 'c'. Now skip to end of conditional.

}else{ //No the user did NOT input 'c'.

document.write(user_input+": is invalid"); //this happens when no previous condition is met.

} //end of conditional

}