Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript If Statement</title> </head> <body> <script> let now = new Date(); let dayOfWeek = now.getDay(); // Sunday - Saturday : 0 - 6 if(dayOfWeek == 5) { document.write("Have a nice weekend!"); } </script> <p><strong>Note:</strong> This example will print "Have a nice weekend!" if the current day is Friday.</p> </body> </html>