@gustavoyepez/

Callbacks 03-1

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Create function canDrink here
var canDrink = (age, callback1, callback2) => {
  if(age >= 21) {
    return callback1();
  } else {
    return callback2();
  }
} 
m
// ===== DO NOT TOUCH CODE BELOW THIS LINE ===== //
var drinkAlcohol = () => {
  return "Drink responsibly!"
}

var drinkSoda = () => {
  return "Come back when you are legally allowed a drink!"
}
// ===== DO NOT TOUCH CODE ABOVE THIS LINE ===== //

canDrink(34, drinkAlcohol,drinkSoda);

// Create a function called canDrink that will take in three parameters. The first parameter will be an number representing an age. The second and third parameters will be callbacks. The functions drinkSoda and drinkAlcohol are examples of callbacks that could be passed into your function.
// If the age is 21 or greater, return drinkAlcohol
// If the age is below 21, return drinkSoda
Native Browser JavaScript