TZinovieva

Car Wash Js Fundamentals

Feb 5th, 2023
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function carWash(arr) {
  2.     let value = 0;
  3.     for (let i = 0; i < arr.length; i++) {
  4.         let command = arr[i];
  5.  
  6.         if (command === "soap") {
  7.             value += 10;
  8.         }
  9.         if (command === "water") {
  10.             value += value * 0.2;
  11.         }
  12.         if (command === "vacuum cleaner") {
  13.             value += value * 0.25;
  14.         }
  15.         if (command === "mud") {
  16.             value -= value * 0.10;
  17.         }
  18.     }
  19.     console.log(`The car is ${value.toFixed(2)}% clean.`);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment