Skip to content

Instantly share code, notes, and snippets.

@pjcodesjs
Last active May 14, 2021 03:02
Show Gist options
  • Save pjcodesjs/db67c3c3e3ad2aa9e2776c3e742d63b4 to your computer and use it in GitHub Desktop.
Save pjcodesjs/db67c3c3e3ad2aa9e2776c3e742d63b4 to your computer and use it in GitHub Desktop.
// REGULAR IF/ELSE
const cat_love_checker = (status) => {
if (status === false) {
return 'Sigh... my cat does not love me :(';
} else {
return 'Aha! My cat does love me!';
}
}
cat_love_checker(false); // Sigh... my cat does not love me :(
// TERNARY OPERATOR
const cat_love_checker = status => (
status === false ? 'Sigh... my cat does not love me :(' : 'Aha! My cat does love me!'
);
cat_love_checker(false); // Sigh... my cat does not love me :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment