user2745194
user2745194

Reputation: 19

if/ else statement not working?

i'm new to coding, and i cant figure out what i am doing wrong. every time i try to write an if/ else, it works up to the point that the statement is, and then it wont work.

this is what i wrote:

alert("welcome to chloe's quiz show!")
var name = prompt("contestant, what is your name?")
var help = prompt("is this your first time playing? type 'yes' or 'no'.")
if (help === yes){
alert("the game is easy! all you have to do is type the letter that corresponds with  the correct answer. then press 'ok'.")
confirm("lets get started!")
}
else{
confirm("lets get started then!")
}

Upvotes: 1

Views: 164

Answers (2)

Emilio Gort
Emilio Gort

Reputation: 3470

if (help === 'yes')

yes is an string, it has to be quoted

Upvotes: 3

anubhava
anubhava

Reputation: 784888

Change this line:

if (help === yes)

to this:

if (help == "yes")

Since yes is not a variable.

Upvotes: 6

Related Questions