Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Last active February 2, 2021 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save sandrabosk/a51a0c77c4954f9ff396d8b46f12e146 to your computer and use it in GitHub Desktop.
Save sandrabosk/a51a0c77c4954f9ff396d8b46f12e146 to your computer and use it in GitHub Desktop.
// Write a function eligibleToDrink() that takes a number as an argument and returns a promise
// that tests if the passed value is less than or greater than the value 18.
// If greater then 18, resolve with 'Being ___ years old, you are eligible to drink'.
// If less then 18, reject with '___ years is underage. Here is a fresh squeezed orange juice for you!'
function eligibleToDrink (age) {
// ... your code
}
eligibleToDrink(15)
.then(result => console.log(result))
.catch(error => console.log(error))
// => 15 years is underage. Here is a fresh squeezed orange juice for you!
eligibleToDrink(18)
.then(result => console.log(result))
.catch(error => console.log(error))
// => Being 18 years old, you are eligible to drink.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment