- 1
What is wrong.
Why this code is not displaying anything. var age = 23; var job; if (age == 24) { job = "guranteed"; } else if (age ==23) { job = "everything is gurAnteed" ; } else job = "Nothing is for you";
8 Answers
+ 12
Because it doesn't have any display statement.
for example, if you write at the end this statement:
document.write(job);
it will display the content of variable job which in this case "everything is gurAnteed".
+ 3
console.log (job) or document.write (job) at end of code will display. unless you give command to display it will not display.
+ 2
and it is good practice to use === instead of ==
+ 2
This code doesn't have any statement to display it. You can use document.write(job) or use console.log(job) after the conditional statement.
+ 2
Why are you expecting to display anything? Answering questions with questions helps learning even more. But I guess it is already answered.
+ 2
var age = 21;
var job;
if (age == 24) {
job = "guranteed";
}
else if (age ==23) {
job = "everything is gurAnteed" ;
}
else
{job = "Nothing is for you"; }
alert (job);
+ 1
no option to display :)
+ 1
Left out a{ for your else statement