if (2<3), console.log (yes)
this does not work. How can I fix this? i want to print "yes" if this is true if not console.log, what this should be?
There are a few errors with your code:
,
because it is invalid syntax. You code should look like this:
if (2<3) console.log ('yes')
Then you should see 'yes' printed in your console.
As others have stated, this is due to syntax problems. There shouldn't be a comma, and the yes should be 'yes' or "yes".
if (2<3) console.log ('yes');
OR
if (2<3) console.log ("yes");
should work how you want it to. JavaScript does not know that you are trying to output a string. What you are doing in the code you provided is actually trying to print out a variable that is named yes. If you would like to print out a variable named yes, it would be something along the lines of
var yes = "yes";
if(2<3) console.log(yes);
Be very careful of syntax!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.