Last active
March 9, 2022 18:26
-
-
Save tiagoamaro/4232f73c8bc55a92cbde9cc1c4bd30c9 to your computer and use it in GitHub Desktop.
Lógica de Programação 2020 - Aula 03
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
if (condition) { | |
// This will execute if condition is true | |
} else if (anotherCondition) { | |
// This will only be executed if condition is false | |
// and another condition is true | |
} |
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
if (condition) { | |
// This will execute if condition is true | |
} else { | |
// Otherwise, this will be executed instead | |
} |
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
if (booleanCondition && anotherBoolean) { | |
// If both are true, this will be executed | |
} |
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
if (condition) { | |
if (anotherCondition) { | |
// This will only be executed the first block | |
} | |
} |
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
if (lampPlugged) { | |
// Check if bulb has burned | |
} else { | |
// Plug the lamp | |
} |
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
if (lampPlugged) { | |
if (burnedBulb) { | |
// Change the bulb | |
} else { | |
// Change the lamp | |
} | |
} else { | |
// Plug the lamp | |
} |
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
let lampPlugged = true | |
let burnedBulb = true | |
if (lampPlugged) { | |
if (burnedBulb) { | |
console.log("Need to change de bulb") | |
} else { | |
console.log("Change the lamp") | |
} | |
} else { | |
console.log("Plug the lamp") | |
} |
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
let quantity = 2 | |
let inStock = true | |
if (inStock) { | |
quantity = quantity - 1 | |
} | |
if (quantity === 0) { | |
inStock = false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment