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 day 2 - 11/28/17 #2

Open
wants to merge 4 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
4 changes: 2 additions & 2 deletions starter-code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head lang="en">
<meta charset="utf-8">
<title>Control Flow</title>
<link
<link>
</head>
<body>

Expand All @@ -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>
49 changes: 49 additions & 0 deletions starter-code/login.js
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
console.log("login.js loaded");

var userLogin = {
username: "kjkeaston",
password: "Passw0rd"
}


/* var credentials = function(msg) {
let login = prompt("enter passwword");
if (login !== userLogin.password) {
callPrompt("re-enter password");
}
return login;
} */

/*let login = prompt("Enter password for user 'kjkeaston'.");
while (login !== userLogin.password) {
alert("Incorrect password. Please try again.");
let retry = prompt("Try password again");
if (retry !== userLogin.password) {
alert("PW still wrong!");
retry;
}
} */

let login = prompt("Enter password for user 'kjkeaston'.");
if (login !== userLogin.password) {
alert("Wrong password");
let retry = prompt("Try you password again");
if (retry !== userLogin.password) {
alert("Still wrong...");
let retryTwo = promopt("Please try it again...");
}
}















38 changes: 38 additions & 0 deletions starter-code/security_questions.js
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
console.log("security_questions.js loaded");

// numIterations ensures this while loop doesn't go on forever
var numIterations = 0;
while (true && numIterations < 100){
console.log("still going!");
numIterations++;
}

secrityQuestions = [
{
question: "What was your the color of your first car?",
expectedAnswer: "red"
},
{
question: "In what city were you born?",
expectedAnswer: "Fort Wayne"
},
{
question: "What is your favorite winter sport?",
expectedAnswer: "skiing"
}
];

for (var i = 0; i < secrityQuestions.length; i++) {
let answer = prompt(secrityQuestions[i].question);
if (answer !== secrityQuestions[i].expectedAnswer) {
alert("Wrong answer!");
break;
}
}








15 changes: 15 additions & 0 deletions starter-code/sing.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
console.log("sing.js loaded");

let question = prompt("How many verses do you want to hear?", "Enter a number less than 100");


for (var i = question; i >= 0; i -=1) {
if (i > 2) {
console.log(i + " bottles of beer on the wall, " + i + " bottles of beer! Take one down, pass it around, " + (i-1) + " bottles of beer on the wall!");
} else if (i ===2) {
console.log(i + " bottles of beer on the wall, " + i + " bottles of beer! Take one down, pass it around, " + (i-1) + " bottle of beer on the wall!");
} else if (i === 1) {
console.log(i + " bottle of beer on the wall, " + i + " bottle of beer! Take one down, pass it around, no more bottles of beer on the wall!");
} else if (i === 0) {
console.log(i + " bottles of beer on the wall, " + i + " bottles of beer! None to take down, none to pass it around, no more bottles of beer on the wall!");
}
}