Skip to content

Instantly share code, notes, and snippets.

@jloescher
Created February 6, 2021 21:11
Show Gist options
  • Save jloescher/4657bdd0b88d1e596114b52bdb2b0c20 to your computer and use it in GitHub Desktop.
Save jloescher/4657bdd0b88d1e596114b52bdb2b0c20 to your computer and use it in GitHub Desktop.
Calculate a tip based on quality of service.
let tipCalculator = (quality, total) => {
switch (quality) {
case 'bad':
return total * 0.05;
break;
case 'ok':
return total * 0.15;
break;
case 'good':
return total * 0.20;
break;
case 'excellent':
return total * 0.30;
break;
default:
return total * 0.18;
}
}
tip = tipCalculator('', 100);
console.log(tip);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment