What's wrong with this code?


#1


`

This code for some reason when answered in any of the two ways gives the response for both statements and i cannot fix it could someone help me?

var userAnswer = prompt("Do you want to race Bieber on stage?")
if(userAnswer="yes")
{
confirm ("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
}
else(userAnswer="no")
{
confirm ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}


#2

You used wrong operator:

if(userAnswer="yes")
...
else(userAnswer="no")

Try == or === instead =

= - assigning operator
== - equal to
=== - equal value and equal type


#3

Thanks for the help it worked and now my script runs just like I wanted it to.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.