Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

2O Lesson 3A

<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script>

//demo 1
document.write("*Demo 1: <br>")
var x = 0;
document.write(x == 5);
document.write("<br>");
document.write(x = 5);
document.write("<br><br>");

//task 1
document.write("Task 1: <br>");
document.write(5 == 5);
document.write("<br>");
document.write(5 == 4);
document.write("<br><br>");

//task 2
document.write("Task 2: <br>");
document.write(0 != 0);
document.write("<br>");
document.write(1 != 2);
document.write("<br><br>");

//task 3 
document.write("Task 3: <br>");
document.write(10 > 10); //false
document.write("<br>");
document.write(10 >= 10); //true
document.write("<br>");
document.write(20 < 20); //false
document.write("<br>");
document.write(20 <= 20); //true
document.write("<br>");
document.write(30 == 30); //true
document.write("<br>");
document.write(30 != 30); //false
document.write("<br><br>");

//demo 2
document.write("*Demo 2: <br>")
var urname = "Mary";
document.write(urname == "Mary");
document.write("<br>");
// TRUE - two strings are exactly the same.
document.write(urname == "Mary ");
document.write("<br>");
// FALSE - additional space
document.write(urname == "MARY");
document.write("<br>");
// FALSE – capitalisation 
document.write(urname == "Jane");
document.write("<br><br>");
// FALSE – completely different

//demo 3
document.write("*Demo 3: <br>")
urname = "Tom";
document.write(urname != "Tom");
document.write("<br>");
// FALSE - two strings are exactly the SAME
document.write(urname != "Tom ");
document.write("<br>");
// TRUE - additional space
document.write(urname != "TOM");
document.write("<br>");
// TRUE - capitalisation
document.write(urname != "John");
document.write("<br><br>");
// TRUE – completely different

//Demo 4
document.write("*Demo 4: <br>")
//var urname = "Michelle";
var urname = prompt("Enter your name:");
if(urname == "Michelle"){
    document.write("Hello Michelle!");
}
else{
    document.write("Hello stranger!");
}
document.write("<br><br>");


</script>
</head>
<body>
</body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.