476179

logicalOperators

Nov 2nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>6</title>
  6. </head>
  7.  
  8. <body>
  9. <script>
  10.  
  11. // ex 1 the AND operator
  12. var a = 123, b = 123, c = "123",d = "123";
  13. if (a === d && c === b)
  14. {
  15. document.write("ex1 a equals b and c equals d");
  16. }
  17. else
  18. {
  19. document.write("ex1 a doesnt equal b and c doesnt equal d");
  20. }
  21.  
  22.  
  23. // ex 2 the OR operator " || "
  24. var e = 123, f = 123, g = "123",h = "123";
  25. if (e === g || g === h)
  26. { // if one is true it ill execute the if
  27.  
  28. document.write("<br><b>ex2 e equals f and g equals h</b>");
  29. }
  30. else
  31. {
  32. document.write("<br>ex2 either e doesnt equal f or g doesnt equal h");
  33. }
  34.  
  35.  
  36.  
  37. </script>
  38. </body>
  39.  
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment