I am just learning and messing around with the built-in Chrome console. Please forgive my structuring. Is there a better area I can ask these beginner questions?
There are two variations that I cannot get to work:
If I am not interested in learning JavaScript, and input a 'no' response, I want a new prompt to show that assigns a newInterest variable, then proceeds to alert 'That is great'.
var interestLevel = prompt('Hello, are you interested in learning JavaScript?')
if (interestLevel == "yes") {
alert('Wonderful, welcome!')
}
if (interestLevel == "no") {
var newInterest = prompt('Then what are you interested in?')
}
The second one should end after a 'yes' response, but it actually goes on to ask the second prompt which should not be the case.
var interestLevel = prompt('Hello, are you interested in learning JavaScript?')
if (interestLevel == "yes") {
alert('Wonderful, welcome!')
}
if (interestlevel == "no") {
alert('That sucks')
}
/* press ok to make the box go away so that the next prompt below will show up */
var newInterest = prompt('Then what are you interested in?')
Aucun commentaire:
Enregistrer un commentaire