https://www.codewars.com/kata/56170e844da7c6f647000063
Codewars - Achieve mastery through coding practice and developer mentorship
A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!
www.codewars.com
DESCRIPTION:
- Kids drink toddy.
- Teens drink coke.
- Young adults drink beer.
- Adults drink whisky.
Make a function that receive age, and return what they drink.
Rules:
- Children under 14 old.
- Teens under 18 old.
- Young under 21 old.
- Adults have 21 or more.
Examples: (Input --> Output)
13 --> "drink toddy"
17 --> "drink coke"
18 --> "drink beer"
20 --> "drink beer"
30 --> "drink whisky"
코드
function peopleWithAgeDrink(old) {
return old >= 21 ? 'drink whisky' : old >= 18 ? 'drink beer' : old >= 14 ? 'drink coke' : 'drink toddy';
};
댓글