+ 5
What's is the Output of this code different from what I expected?
var age = 42; var isAdult = (age < 18) ? "Too young": "Old enough"; document.write(isAdult); Isn't the output supposed to be "Too young" according to the statement when age is less than 18. But I'm seeing "Old enough" as the output. Now I'm confused. Pls help guys
3 Answers
+ 2
Read that line as follows ...
if age less than 18 then
let isAdult value be "Too young"
else
let isAdult value be "Old enough"
+ 4
Oh I understand now! And age is 45 whereby greater than 18. Thanks so much
- 1
The value of age already is 42,which is greater than 18 in normal terms Soo the output is too young