Last active
May 23, 2020 20:03
-
-
Save tiagoamaro/5d0d29715ee9a04ae0277b5031651735 to your computer and use it in GitHub Desktop.
Lógica de Programação 2020 - Aula 05
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
function sum (a, b) { | |
return a + b | |
} | |
let result = sum(2, 2) | |
console.log(result) |
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
function welcomeMessage (hour) { | |
if (hour < 12) { | |
console.log('Good morning') | |
} else if (hour >= 12 && hour <= 17) { | |
console.log('Good afternoon') | |
} else if (hour > 17) { | |
console.log('Good night') | |
} | |
} | |
welcomeMessage(10) // will print "Good morning" | |
welcomeMessage(15) // will print "Good afternoon" | |
welcomeMessage(21) // will print "Good night" |
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
Math.pow(2, 3) // base 2, exponent 3. Same as 2³ | |
Math.random() |
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
function factorial (number) { | |
if (number <= 1) { | |
return 1 | |
} else { | |
return number * factorial(number - 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment