Ivankooo1

washCar

Feb 7th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.   let functs ={
  3.       soap: x => x + 10,
  4.       water: x => x + x * 0.20,
  5.       'vacuum cleaner': x => x + x * 0.25,
  6.       mud: x => x - x * 0.10
  7.   }
  8.  
  9.   let value = input.reduce((acc, curr) => functs[curr](acc), 0);
  10.   console.log(`The car is ${value.toFixed(2)}% clean.`);
  11. }
  12.  
  13. solve(['soap','soap','vacuum cleaner','mud','soap','water']);
Advertisement
Add Comment
Please, Sign In to add comment