Use examples of if else conditional statements in JavaScript

From , 3 Years ago, written in JavaScript, viewed 136 times.
URL https://pastebin.vip/view/51db672a
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <p>Click the button to get a time-based greeting.</p>
  6.  
  7. <button onclick="myFunction()">Try it</button>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. function myFunction()
  13. {
  14. var x="";
  15. var time=new Date().getHours();
  16. if (time<20)
  17.   {
  18.   x="Good day";
  19.   }
  20. else
  21.   {
  22.   x="Good evening";
  23.   }
  24. document.getElementById("demo").innerHTML=x;
  25. }
  26. </script>
  27.  
  28. </body>
  29. </html>
  30.  
  31. //javascript/7824

Reply to "Use examples of if else conditional statements in JavaScript"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website