If-2

 

In this example, We have a flag variable with true as its value. 

var flag= true; if(flag){ document.write("flag is true."); }

 It will return "flag is true" statement.

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <script> var flag= true; if(flag){ document.write("<b>flag is true.</b>"); } </script> </body> </html>
Output