New to Javascript but not programming in general and my else if won’t execute when I type in 31. Anyone know why this wouldn’t work?
var age = prompt(“Enter age”);
if(age >= 21) {
alert(“Good”);
}
else if (age === 31) {
console.log(“Perfect”);
}
I swore the guy in the tutorial I watched said use “====” all the time because it’s safer. Anyhow, thanks.
It’s still not working for me. Nothing appears in the console when == is used.
Got it to work doing this. Can’t say I’m a fan of how Javascript handles this.
Edit: Didn’t know there was a typeof method. Good to know. I literally picked up this language for the first time like an hour ago.
var age = Number(prompt("Enter age"));
if(age <= 21) {
alert("Good");
}
else if (age == 31) {
console.log("Perfect");
}