DEV Community

Discussion on: Daily Challenge #56 - Coffee Shop

Collapse
 
kvharish profile image
K.V.Harish

My solution in js

const getACoffee = (amount) => {
  const menu = {'2.2': 'Americano', '2.3': 'Latte', '2.4': 'Flat white', '3.5': 'Filter'},
    coffeeType = menu[`${parseFloat(amount)}`];
  return coffeeType ? `Here is your ${coffeeType}, have a nice day!` : 'Sorry, exact change only, try again tomorrow!'
};