Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //first block
- let isLocked = false;
- //using if-else statement
- if (isLocked) {
- console.log('You will need a key to open the door.');
- } else {
- console.log('You will not need a key to open the door.');
- }
- //using ternary operator to replace if-else statement
- isLocked ? console.log('You will need a key to open the door.') : console.log('You will not need a key to open the door.');
- //second block
- let favoritePhrase = 'Love That!';
- //using if-else statement
- if (favoritePhrase === 'Love That!') {
- console.log('I love that!');
- } else {
- console.log("I don't love that!");
- }
- //using ternary operator to replace if-else statement
- favoritePhrase === 'Love That!' ? console.log('I love that!') : console.log("I don't love that!");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement