Advertisement
Spocoman

01. Car Wash

Jan 30th, 2022
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function carWash (commands) {
  2.     let value = 0;
  3.  
  4.     while (commands.length !== 0){
  5.         switch (commands.shift()) {
  6.             case 'soap':
  7.                 value += 10;
  8.                 break;
  9.             case 'water':
  10.                 value *= 1.2;
  11.                 break;
  12.             case 'vacuum cleaner':
  13.                 value *= 1.25;
  14.                 break;
  15.             case 'mud':
  16.                 value *= 0.9;
  17.                 break;
  18.  
  19.         }
  20.     }
  21.     console.log(`The car is ${value.toFixed(2)}% clean.`)
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement