01. Car Wash
1.Car Wash
Write a JS function that receives some commands. Depending on the command add a percentage of how much the car is cleaned. Start from 0. The first command will always be 'soap':
- soap – add 10 to the value
- water – increase the value with 20%
- vacuum cleaner – increase the value with 25%
- mud – decrease the value with 10%
The input comes as an array strings. When finished cleaning the car, print the resulting value in the format:
"The car is {value}% clean.". The value should be rounded to the second decimal point.
Examples
Input |
Output |
['soap', 'soap', 'vacuum cleaner', 'mud', 'soap', 'water'] |
The car is 39.00% clean. |
Задачата е доста лесна, но исках да я направя с 4 отделни функции, за всяка команда, за да ги упражня, но не мога да разбера защо 'value' не ми се ъпдейтва. Сигурно е нещо елементарно, но не го виждам.
Ето го кода: https://pastebin.com/ZX6YjEk7