Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework for Week 1 day 2 #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solutions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p>Open your console!</p>
<p>You should see a message saying your JavaScript has loaded.</p>

<!-- <script type="text/javascript" src="login.js"></script> -->
<script type="text/javascript" src="login.js"></script>
<!-- <script type="text/javascript" src="security_questions.js"></script> -->
<!-- <script type="text/javascript" src="sing.js"></script> -->

Expand Down
8 changes: 8 additions & 0 deletions solutions/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ var passwordInput;

var loggedIn = false;








while (!loggedIn){
passwordInput = prompt("Enter password for user " + userLogin.userName + ".")
if (passwordInput === userLogin.password){
Expand All @@ -15,3 +22,4 @@ while (!loggedIn){
console.log("Passwords do not match. Try Again!");
}
}

2 changes: 1 addition & 1 deletion starter-code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<!-- <script type="text/javascript" src="login.js"></script> -->
<!-- <script type="text/javascript" src="security_questions.js"></script> -->
<!-- <script type="text/javascript" src="sing.js"></script> -->
<script type="text/javascript" src="sing.js"></script>

</body>
</html>
18 changes: 18 additions & 0 deletions starter-code/login.js
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
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;
}
}
34 changes: 34 additions & 0 deletions starter-code/security_questions.js
Original file line number Diff line number Diff line change
@@ -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;

};
};








20 changes: 20 additions & 0 deletions starter-code/sing.js
Original file line number Diff line number Diff line change
@@ -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!");
}
}