From a92fc36853b7eb54cf5b1574e5ded96ee81dcecf Mon Sep 17 00:00:00 2001 From: Xianyi555 Date: Tue, 28 Nov 2017 16:28:37 -0800 Subject: [PATCH 1/2] change a mark --- starter-code/login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starter-code/login.js b/starter-code/login.js index 3ec61ba..51e2379 100644 --- a/starter-code/login.js +++ b/starter-code/login.js @@ -1 +1 @@ -console.log("login.js loaded"); +console.log("login.js loaded"!); From 8489e070eed08f32d4965446e8dc8a0fd2fdb2cc Mon Sep 17 00:00:00 2001 From: Xianyi555 Date: Wed, 29 Nov 2017 01:33:25 -0800 Subject: [PATCH 2/2] homework complete --- solutions/index.html | 2 +- solutions/login.js | 8 +++++++ starter-code/index.html | 2 +- starter-code/login.js | 20 +++++++++++++++++- starter-code/security_questions.js | 34 ++++++++++++++++++++++++++++++ starter-code/sing.js | 20 ++++++++++++++++++ 6 files changed, 83 insertions(+), 3 deletions(-) diff --git a/solutions/index.html b/solutions/index.html index eed6a96..415e0ff 100644 --- a/solutions/index.html +++ b/solutions/index.html @@ -11,7 +11,7 @@

Open your console!

You should see a message saying your JavaScript has loaded.

- + diff --git a/solutions/login.js b/solutions/login.js index 176a6e5..0ceccfb 100644 --- a/solutions/login.js +++ b/solutions/login.js @@ -6,6 +6,13 @@ var passwordInput; var loggedIn = false; + + + + + + + while (!loggedIn){ passwordInput = prompt("Enter password for user " + userLogin.userName + ".") if (passwordInput === userLogin.password){ @@ -15,3 +22,4 @@ while (!loggedIn){ console.log("Passwords do not match. Try Again!"); } } + diff --git a/starter-code/index.html b/starter-code/index.html index eed6a96..d9a70d5 100644 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -13,7 +13,7 @@ - + diff --git a/starter-code/login.js b/starter-code/login.js index 51e2379..f1691e9 100644 --- a/starter-code/login.js +++ b/starter-code/login.js @@ -1 +1,19 @@ -console.log("login.js loaded"!); +console.log("login.js loaded"); + +var userLogin = { + userName: "Jims", + userPassword: "abcd" +}; + +var loggedIn = false; + + for (var i = 0; i <3; i++) { + var passwordInput = prompt("Enter password for user " + userLogin.userName + "."); + if (passwordInput != userLogin.userPassword){ + console.log("Passwords do not match. Try Again!"); + } else { + loggedIn = true; + console.log("Passwords match!"); + break; + } +} diff --git a/starter-code/security_questions.js b/starter-code/security_questions.js index 03606fe..e7009ee 100644 --- a/starter-code/security_questions.js +++ b/starter-code/security_questions.js @@ -1 +1,35 @@ console.log("security_questions.js loaded"); + +var securityQuestions = [ + { + question: "What was your first pet's name?", + expectedAnswer: "dog" + }, + { + question: "What is your mother's first name?", + expectedAnswer: "Susan" + }, + { question: "What is your dad's first name?", + expectedAnswer: "Sam" + + } + ] + +var anserInput = ""; + + for (var i = 0; i < securityQuestions.length; i++) { + anserInput = prompt(securityQuestions[i].question); + if (anserInput !== securityQuestions[i].expectedAnswer) { + alert("It is a incorrect answer!"); + break; + + }; + }; + + + + + + + + diff --git a/starter-code/sing.js b/starter-code/sing.js index c656175..a5e91b4 100644 --- a/starter-code/sing.js +++ b/starter-code/sing.js @@ -1 +1,21 @@ console.log("sing.js loaded"); + + +var numBottles = prompt("How many bottles of beer on the wall?"); + +var bottles = "bottles"; +while (numBottles > 0){ + console.log(numBottles + " " + bottles + " of beer on the wall,"); + console.log(numBottles + " " + bottles + " of beer"); + console.log("Take one down and pass it around,"); + numBottles = numBottles - 1; + + if (numBottles === 1){ + bottles = "bottle" + } + if (numBottles === 0){ + console.log("No more bottles of beer on the wall!"); + } else { + console.log(numBottles + " " + bottles + " of beer on the wall!"); + } +}