Created
March 22, 2023 14:48
-
-
Save periakteon/d8bd0d52170977638e6237d29487c9d8 to your computer and use it in GitHub Desktop.
FreeCodeCamp: Use Multiple Conditional (Ternary) Operators (Solution)
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
function checkSign(num) { | |
// eğer 0'dan büyükse, "positive" stringi döndür ( if ) | |
return num > 0 ? "positive" | |
// eğer 0'dan küçükse, "negative" stringi döndür (else if) | |
: num < 0 ? "negative" | |
// kalan tüm durumlarda "zero" döndür ( else ) | |
: "zero" | |
} | |
console.log(checkSign(10)); | |
// positive | |
console.log(checkSign(-10)); | |
// negative | |
console.log(checkSign(0)); | |
// zero |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment