Created
February 6, 2021 21:11
-
-
Save jloescher/4657bdd0b88d1e596114b52bdb2b0c20 to your computer and use it in GitHub Desktop.
Calculate a tip based on quality of service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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