Answer the question
In order to leave comments, you need to log in
What's wrong here!? Topic if.?
Hello, I'm new to learning JS, so I'm asking for your help...
Explain to me what's wrong here. I already didn’t mock this script, it doesn’t work, it doesn’t want to work - it writes - "You were born in undefinedNaN months from your birthday, until the end of the year." Help....
alert("Task: Enter the month you were born in (number)")
var mount = prompt("Month is ", '');
var mounts
if (mount == 1){
mount=("January");
}
else if (mount == 2){
mount=("February");
}
else if (mount == 3){
mount=("March");
}
else if (mount == 4){
mount=("April");
}
else if (mount == 6){
mount=("June");
}
else if (mount == 7){
mount=("July");
}
alert("You were born in "+ mounts + (12 - mount) + " months from your birthday, until the end of the year.")
Answer the question
In order to leave comments, you need to log in
1)
replace
with you get the string written in mount, after entering the value you need to convert it from the string to a number, you can do it simply by putting +
2) perform strict checks through ===
3) mount = ("January") you overwrite the desired string number, apparently the error needs mounts
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question