Javascript examples for Statement:Quiz
Add curly braces to if/else statement
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var greeting;//from ww w . j a va2 s. c om var hour = new Date().getHours(); if (hour < 18) { greeting = "Good day"; } else { greeting = "Good evening"; } document.getElementById("demo").innerHTML = greeting; </script> </body> </html>