Skip to content

Instantly share code, notes, and snippets.

@tiagoamaro
Last active May 23, 2020 20:03
Show Gist options
  • Save tiagoamaro/5d0d29715ee9a04ae0277b5031651735 to your computer and use it in GitHub Desktop.
Save tiagoamaro/5d0d29715ee9a04ae0277b5031651735 to your computer and use it in GitHub Desktop.
Lógica de Programação 2020 - Aula 05
function sum (a, b) {
return a + b
}
let result = sum(2, 2)
console.log(result)
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"
Math.pow(2, 3) // base 2, exponent 3. Same as 2³
Math.random()
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