Last active
June 30, 2021 00:43
-
-
Save natafaye/fcd6201065a687afea86a86bd11f87f0 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
| // Bitter Magic 8-Ball | |
| let question = prompt("What's your question?"); | |
| let firstName = prompt("What's your name?"); | |
| if(question === null) { | |
| if(firstName === "Bob") { | |
| alert("Have a great day!"); | |
| } | |
| else { | |
| alert("Fine then."); | |
| } | |
| } | |
| else if(!question.includes("?")) { | |
| alert("Is that even a question?"); | |
| } | |
| else if(question.startsWith("Should I")) { | |
| alert("Don't do it."); | |
| } | |
| else if(question.includes("love")) { | |
| alert("THEY DON'T LOVE YOU"); | |
| } | |
| else { | |
| alert("Maybe"); | |
| } | |
| // Number Guessing Game | |
| let answer = 7; | |
| let guess; | |
| do { | |
| guess = prompt("What number am I thinking of?"); | |
| if(guess === null) { | |
| break; | |
| } | |
| //guess = parseInt(guess); | |
| } while(parseInt(guess) !== answer) | |
| if(guess === answer) { | |
| alert('You win!') | |
| } | |
| // Counting Practice | |
| let howHigh = parseInt(prompt("How high should I count?")); | |
| // let howHigh = prompt("How high should I count?"); | |
| // howHigh = parseInt(howHigh); | |
| while(isNaN(howHigh)) { | |
| if(howHigh === null) { | |
| alert("Goodbye!") | |
| break; | |
| } | |
| howHigh = parseInt(prompt("That's not a number. How high should I count?")); | |
| } | |
| if(howHigh !== null) { | |
| for(let i = 0; i < howHigh; i++) { | |
| alert(i + 1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment