0

can i know a reason of the fail of my coding?

I made the code like this but it doesn't work. I can't see any output although I can see the prompt box can I know a reason?? var age = prompt("enter your age"); var isAdult = (age <18) ? "Too young": (age <30) ? "middle": (age <40)? "last": (age <50) ? "old":

19th Apr 2018, 4:53 AM
지승희
지승희 - avatar
1 Réponse
0
The last ternary is not terminated correctly. Try this: var isAdult= age<18?"Too Young" : age<30?"middle": age<40?"last" : "old" ; Pay attention to the last row, where I have omitted your "age<50"
8th Jun 2024, 9:59 AM
Simone Leoni
Simone Leoni - avatar