Created
October 11, 2021 11:52
-
-
Save Blazing-Mike/0f1447eb97cccf24b94301da46629869 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
// Learning ternary operators | |
// Traditional way | |
let message; | |
if (login == 'Employee') { | |
message = 'Hello'; | |
} else if (login == 'Director') { | |
message = 'Greetings'; | |
} else if (login == '') { | |
message = 'No login'; | |
} else { | |
message = ''; | |
} | |
// Using ternary operator | |
let message = (login == "Employee") ? "hello" : | |
(login == "Director") ? "Greetings" : | |
(login == "") ? "No login" : ""; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment