- 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";

25th Sep 2016, 5:08 AM
Muhammad Umar
Muhammad Umar - avatar
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".
26th Sep 2016, 1:08 AM
Mohammed Chetehouna
+ 3
console.log (job) or document.write (job) at end of code will display. unless you give command to display it will not display.
26th Sep 2016, 1:40 PM
Kriti Bansal
Kriti Bansal - avatar
+ 2
and it is good practice to use === instead of ==
28th Sep 2016, 10:30 PM
Lukwago
Lukwago - avatar
+ 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.
5th Oct 2016, 8:38 AM
Everistus Olumese
Everistus Olumese - avatar
+ 2
Why are you expecting to display anything? Answering questions with questions helps learning even more. But I guess it is already answered.
12th Nov 2016, 1:53 PM
Fernando Soares
Fernando Soares - avatar
+ 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);
18th Nov 2016, 5:22 AM
somanath shahapurkar
somanath shahapurkar - avatar
+ 1
no option to display :)
21st Nov 2016, 6:05 AM
Arun Bhandari
Arun Bhandari - avatar
+ 1
Left out a{ for your else statement
20th Dec 2016, 9:33 PM
LBC_Shadow