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