How to represent this blocks in Javascript?
1 Like
Lets assume isCar is a variable that store data like it does in you global var
Simple Code :
if(isCar){ var str = "a car"; }else{ var str = "not a car"; }
var text = "Its " + str
Another way:
var str = (isCar) ? "a car" : "not a car";
var text = "Its " + str;
If isCar is true then output would be Its a car else Its not a car
1 Like
Based on this, I found another way:
var text = "Its "+((isCar) ? "a car" : "not a car");
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.