Coffee shop #56
by jacobwsmith
JavaScript
console.clear();
// Write a function that returns, "Here is your "+type+", have a nice day!" if they have the right change or returns "Sorry, exact change only, try again tomorrow!"
const getDrink = (amount) => {
// Americano £2.20, Latte £2.30, Flat white £2.40 and Filter £3.50
const drinks = {
2.20: 'Americano',
2.30: 'Latte',
2.40: 'Flat white',
3.50: 'Filter'
};
return drinks[amount] ? `Here is your ${drinks[amount]}, have a nice day` : 'Sorry, exact change only, try again tomorrow!';
}
console.log(getDrink(2.20));
console.log(getDrink(5.00));