What is wrong with my code

Here’s my code than produces an “unexpected token else”, I tried the switch syntax and it worked fine. However i can’t make it work with multiple if’s.

const tipCalculator = (quality, totalCost)=>
{
if (quality===“bad”){return 0.05totalCost};
else if (quality===“ok”){return 0.15
totalCost};
else if (quality===“good”){return 0.2totalCost};
else if (quality===“excellent”){return 0.3
totalCost};
else {return 0.18*totalCost};}
console.log (tipCalculator(“bad”, 60))
console.log(tipCalculator(‘good’, 100))

You can find the exercise here https://www.codecademy.com/paths/front-end-engineer-career-path/tracks/fecp-22-javascript-syntax-part-i/modules/wdcp-22-practice-javascript-syntax-variables-data-types-conditionals-functions/lessons/javascript-fundamentals-code-challenge/exercises/tip-calculator

You have };
but those should be ;}

1 Like

cant thank you enough. You’re a star

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.