0
Can't understand a little bit ...
Hi ! I can't understand the second line of code . Here it is : var age = 14; var isAdult = (age < 18) ? "Too young": "Old enough"; /*This one*/ document.write(isAdult);
4 Antworten
+ 9
a ? b : c
is similar to
if (a)
{
b
}
else c
***
Looking back at the second line,
if (age < 18)
{
isAdult = "Too young";
}
else
{
isAdult = "Old enough";
}
+ 1
Hatsy Is correct.
the ? : operator has three components
Condition? if true: if false;
If condition is true then the part directly after the ? is performed. Otherwise the last part is performed.
0
Thanks
0
thanks