Advertisement
benjaminvr

Codecademy - Switch for tips

Jul 7th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let tipCalculator = (quality, total) => {
  2.   switch(quality){
  3.     case 'bad':
  4.       return total*0.05;
  5.       break;
  6.     case 'ok':
  7.       return total*0.15;
  8.       break;
  9.     case 'good':
  10.       return total*0.2;
  11.       break;
  12.     case 'excellent':
  13.       return total*0.3;
  14.       break;
  15.     default:
  16.       return total*0.18;
  17.       break;
  18.   }
  19. }
  20.  
  21. console.log(tipCalculator('good', 100));
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement