Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- let [start, operation1, operation2, operation3, operation4, operation5]
- = [Number(arr[0]), arr[1], arr[2], arr[3], arr[4], arr[5]];
- let chop = (num) => num / 2;
- let dice = (num) => Math.sqrt(num);
- let spice = (num) => num + 1;
- let bake = (num) => num * 3;
- let fillet = (num) => num -= num * 0.20;
- for (let operation of [operation1, operation2, operation3, operation4, operation5]) {
- switch(operation) {
- case 'chop': start = chop(start);
- break;
- case 'dice': start = dice(start);
- break;
- case 'spice': start = spice(start);
- break;
- case 'bake': start = bake(start);
- break;
- case 'fillet': start = fillet(start);
- break;
- }
- console.log(start);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement