- 3

Please given me a example of this code, operator: a > b ? alert(a) : alert(b).

And is this code similar to this code ,var isadult =(age<18)?"young ":"old";

13th Sep 2020, 12:58 PM
RD:programmer
RD:programmer - avatar
2 odpowiedzi
+ 5
Yes this code is similar. This code basically shortcut of if else statement. if a>b is true so alert a Else condition is false so alert b
13th Sep 2020, 1:00 PM
Akash Agrawal
Akash Agrawal - avatar
+ 3
Yes, it's similar to that code. variable = (condition) ? statement-1 : statement-2 Also similar too, if(a > b){ alert(a); }else{ alert(b); } https://www.sololearn.com/learn/JavaScript/1133/?ref=app https://www.sololearn.com/learn/JavaScript/1149/?ref=app
13th Sep 2020, 1:08 PM
Jenson Y