Last active
September 11, 2023 20:30
-
-
Save audunolsen/aa3642f698e986ced42f09e1d53405dc to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* Here's an alternative approach that uses the ternary operator instead of `if/else`. | |
* It does just the same as the other example just expressed slightly differently. | |
* | |
* DOCS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator | |
*/ | |
const secret = "coconut" | |
const guess = prompt() | |
const response = guess === secret ? "Ding ding!!" : "Nope…" | |
alert(response) |
This file contains 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
const secret = "coconut" | |
const guess = prompt() | |
if (guess === secret) { | |
alert("+10 points") | |
} else { | |
alert("No bueno") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment