Last active
December 9, 2021 02:58
-
-
Save natafaye/b39b0102efcef23fd2823353b5e816f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<script src="week2.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rigged Magic 8-Ball | |
// Ask the user for their question | |
var question = prompt("What's your question"); | |
// Keep asking them for their question until they give a question | |
while(!question.includes("?")) { | |
question = prompt("What's your QUESTION"); | |
} | |
// Check the question for a few things | |
// Give them an answer | |
if(question.includes("money")) { | |
alert("YESSS") | |
} | |
else if(question.includes("love")) { | |
alert("NOOOO") | |
} | |
else { | |
alert("Maybe") | |
} | |
// Counting Practice Problem | |
// Ask the user for a number to count to | |
var number = prompt("What number should I count to?"); | |
number = parseInt(number); | |
// Keep asking until they give a number | |
while(number === NaN) { | |
number = prompt("What number should I count to?"); | |
number = parseInt(number); | |
} | |
// Count up to that number, starting at 1, logging each number you count to the console (or alerting it) | |
for(let i = 0; i < number; i++) { | |
// The code to run multiple times | |
alert(i + 1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment