<!DOCTYPE html> <html> <title>Web Page Design</title> <head> <script> var weather = prompt("is the weather cloudy?Enter yes or no:"); if (weather =="yes") { document.write("Bring an umbrella out with you!"); } else { document.write("go out and play!"); } </script> </head> <body> </body> </html>
<!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>
<!DOCTYPE html> <html> <title>Web Page Design</title> <head> <script> //task 1 document.write(5 == 5); document.write("<br>"); document.write(5 == 4); document.write("<br>"); //task 2 document.write(0 != 0); document.write("<br>"); document.write(1 != 2); document.write("<br>"); //task 3 document.write(10>10); document.write("<br>"); document.write(10>=10); document.write("<br>"); document.write(20<20); document.write("<br>"); document.write(20<=20); document.write("<br>"); document.write(30==30); document.write("<br>"); document.write(30!=30); //demo 2 var urname = "pizza savers"; document.write("<br>"); document.write(urname == "pizza savers"); document.write("<br>"); document.write(urname == "pizza savers "); document.write("<br>"); document.write(urname == "PIZZA SAVERS"); document.write("<br>"); document.write(urname == "im hungry"); //demo 3 urname = "round pizza boxes"; document.write("<br>"); document.write(urname!="round pizza boxes"); document.write("<br>"); document.write(urname!="round pizza boxes "); document.write("<br>"); document.write(urname!="ROUND PIZZA BOXES"); document.write("<br>"); document.write(urname!="squarE"); //demo 4 var urname = prompt("enter your name:"); document.write("<br>"); if(urname == "hyunjin") { document.write("hello you legend"); } else { document.write("tsk you're not hyunjin"); } </script> </head> <body> </body> </html>
<!DOCTYPE html> <html> <title>Web Page Design</title> <head> <script> //Task 1 document.write(5 == 5); document.write("<br>"); document.write(5 == 4); document.write("<br>"); document.write("<br>"); //Task 2 document.write(0 != 0); document.write("<br>"); document.write(1 != 2); document.write("<br>"); document.write("<br>"); //Task 3 document.write(10 > 10); document.write("<br>"); document.write(10 >= 10); document.write("<br>"); document.write(20 < 20); document.write("<br>"); document.write(20 <= 20); document.write("<br>"); document.write(30 == 30); document.write("<br>"); document.write(30 != 30); document.write("<br>"); document.write("<br>"); //Demo 2 (var have to be exact to be true) var urname = "Mary"; document.write(urname == "Mary"); document.write("<br>"); document.write(urname == "Mary "); document.write("<br>"); document.write(urname == "MARY"); document.write("<br>"); document.write(urname == "Cherry"); document.write("<br>"); document.write("<br>"); //Demo 3 var urname = "Sae"; document.write(urname != "Sae"); document.write("<br>"); document.write(urname != "Sae "); document.write("<br>"); document.write(urname != "SAE"); document.write("<br>"); document.write(urname != "Moon"); document.write("<br>"); document.write("<br>"); //Demo 4 var urname = prompt ("Enter you Name: "); //var urname = "Sae"; if(urname == "Sae") { document.write("Hello Sae!"); } else{ document.write("Bye Stranger!"); } </script> </head> <body> </body> </html>
<!DOCTYPE html> <html> <title>Web Page Design</title> <head> <script> //task 1 document.write(5==5); document.write("<br>"); document.write(5==4); document.write("<br>"); //task 2 document.write(0!=0); document.write("<br>"); document.write(1!=2); document.write("<br>"); //task 3 document.write(10>10); document.write(10>=10); document.write(20<20); document.write(20<=20); document.write(30!=30); //task 4 var urname="Lexi"; document.write(urname=="Lexi"); document.write("<br>"); document.write(urname=="Lexi"); document.write("<br>"); document.write(urname=="LEXI"); document.write("<br>"); document.write(urname=="jeffree star"); //task 5 var urname="Lexi"; document.write(urname!="Lexi"); document.write("<br>"); document.write(urname!="Lexi"); document.write("<br>"); document.write(urname!="LEXI"); document.write("<br>"); document.write(urname!="jeffree star"); //task 6 var urname=prompt("Enter your name!"); if(urname =="brit"){ document.write("hello brit!") } else{ document.write("hello stranger!") } document.write("<br><br>") </script> </head> <body> </body> </html>
<html> <title>Web Page Design</title> <head> <script> document.write("Check the Weather!" + "<br><br>") document.write("Is it cloudy?" + "<br><br>") var theweather = prompt("Is the weather cloudy?:"); if(theweather == "yes") { document.write("Bring your umbrella!") } else{ document.write("Go out and play!")} document.write("<br><br>") </script> </head> <body> </body> </html>
<!DOCTYPE html> <html> <title>Web Page Design</title> <head> <script> //demo 2 document.write("Demo 2<br>") var name = prompt("What is your name?"); if(name == "Mary") { var colour = prompt("Guess a colour, Mary!"); while(colour != "Red") { colour = prompt("Guess again, Mary!"); } document.write("Yay! You guessed Red, Mary!"); } else { document.write("You’re not Mary!"); } document.write("<br> <br>") //task 4 document.write("Task 4<br>") var urage = prompt("Enter your age:"); if(urage <= 15 ) { var guesscolour = prompt("Guess a colour!"); guesscolour = guesscolour.toUpperCase() while(guesscolour != "RED") { guesscolour = prompt("Wrong! Guess again!"); } document.write("Yay! You guessed red!"); } else { var guessnum = prompt("Guess a number, Mary!"); while(guessnum != 7) { guessnum = prompt("Wrong! Guess again!"); } document.write("Yay! You guessed 7!"); } document.write("<br> <br>") </script> </head> <body> </body> </html>
<!DOCTYPE html> <html> <title>Web Page Design</title> <head> <script> document.write("=== Report Card ===<br>"); document.write("Name:"+"Mary Lim <br>"); document.write("Class:"+"2A <br>"); document.write("Index No.:"+"27<br>"+"<br>"); document.write("=== Grades ===<br>"); document.write("English:"+"85"+"/100"+"(A)<br>"); document.write("Mother Tongue :"+"72"+"/100"+"(B)<br>"); document.write("Science :"+"69"+"/100"+"(C)<br>"); document.write("Maths :"+"82"+"/100"+"(D)<br>"); var urname = prompt ("Enter your name :"); var urclass = prompt ("Enter your class :<br>"); var urindex = prompt ("Enter your index :<br>"); var urengmark = prompt ("Enter your English Marks :"); var urmtmrk = prompt ("Enter your Mother Tongue Marks :<br>"); var urscimrk = prompt ("Enter your Science Marks :<br>"); var urmathmrk = prompt ("Enter your Math Marks :<br>"); document.write("=== Report Card ===<br>"); document.write("Name:"+ urname " <br>"); document.write("Class:"+urclass "<br>"); document.write("Index No.:"+urindex"<br>"); document.write("=== Grades ===<br>"); document.write("English:"+urengmark+"/100"+"(A)<br>"); document.write("Mother Tongue :"+urmtmrk+"/100"+"(B)<br>"); document.write("Science :"+ urscimrk+"/100"+"(C)<br>"); document.write("Maths :"+urmathmrk +"/100"+"(D)<br>"); </script> </head> <body> </body> </html>
<!DOCTYPE html> <html> <head> <title>Array</title> </head> <body> <div id="names-list"></div> <script> // Array let names = ['Larry', 'Curly', 'Moe']; // Construct HTML unordered list containing the list of names in the array let html = '<ul>'; // Parse the name out of the names array using a for loop // The "length" property is used to retrive the size of the array (# of indexes) for (let i=0;i<names.length;i++) { // += concatenates and assigns the strings the the "html" variable html += '<li>' + names[i] + '</li>'; } html += '</ul>'; // Reference the "names-list" id located in the HTML let list = document.querySelector('#names-list'); list.innerHTML = html; </script> </body> </html>