Created
December 17, 2022 13:41
-
-
Save thebigdatajedi/2806adf8cf110b810f91848b27bc350f to your computer and use it in GitHub Desktop.
ternary explanation with example
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
//This is how a ternary operator works: | |
//<condition to check> ? <what happens if the condition is true> : <what happens | |
//if the condition is false>; | |
//Credit Union System example with evaluating fees. | |
function getFee(isMember: boolean): string { | |
return (isMember ? '$2.00' : '$10.00'); | |
} | |
let fee = getFee(true); | |
console.log(fee); //this would print $2.00 to the console. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment