Conditionals in Javascript by Ctrl-Zombies
Categories: HomeworkConditionals homework in Javascript
Conditionals Javascript Homework - CTRL Zombies
Javascript Popcorn Hack
Finish the else function in the program. Then run the code cell in the console to see if it works.
%%js
let snakeDead = true;
if (snakeDead === false) {
console.log("Continue game");
} else {
console.log("Game over");
}
Part C: JavaScript Practice
Here you will make a similar program as the Python program but in Javascript. Then change your program so that it prints:
-
“Excellent” if the score is ≥ 90
-
“Good” if the score is between 60 and 89
-
“Fail” if the score is below 60
%%js
// <-- Example Code
let x = 19;
if (x >= 18) {
console.log("You can vote");
} else {
console.log("You are too young to vote");
}
<IPython.core.display.Javascript object>
%%js
let score = 75;
if (score >= 90) {
console.log("Excellent");
} else if (score >= 60 && score <= 89) {
console.log("Good");
} else {
console.log("Fail");
}
<IPython.core.display.Javascript object>