Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function carWash(arr) {
- let value = 0;
- for (let i = 0; i < arr.length; i++) {
- let command = arr[i];
- if (command === "soap") {
- value += 10;
- }
- if (command === "water") {
- value += value * 0.2;
- }
- if (command === "vacuum cleaner") {
- value += value * 0.25;
- }
- if (command === "mud") {
- value -= value * 0.10;
- }
- }
- console.log(`The car is ${value.toFixed(2)}% clean.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment