I did it three different ways, but here's what I ended up with as probably the cleanest:
JS
constcoffee=(amount)=>{letdrinktype={2.2:"Americano",2.3:"Latte",2.4:"Flat white",3.5:"Filter",}[amount]if(drinktype){return"Here is your "+drinktype+", have a nice day!"}else{return"Sorry, exact change only, try again tomorrow!"}}
You can watch me solve it here, plus see the other two solutions (and a bonus discussion about why not to use floats for currency in JS 😂): youtu.be/HtvBlId7tig
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I did it three different ways, but here's what I ended up with as probably the cleanest:
JS
You can watch me solve it here, plus see the other two solutions (and a bonus discussion about why not to use floats for currency in JS 😂): youtu.be/HtvBlId7tig