Advertisement
-Annie-

CookingByNumbers

May 30th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.     let [start, operation1, operation2, operation3, operation4, operation5]
  3.         = [Number(arr[0]), arr[1], arr[2], arr[3], arr[4], arr[5]];
  4.  
  5.     let chop = (num) =>  num / 2;
  6.     let dice = (num) =>  Math.sqrt(num);
  7.     let spice = (num) =>  num + 1;
  8.     let bake = (num) =>  num * 3;
  9.     let fillet = (num) => num -= num * 0.20;
  10.  
  11.     for (let operation of [operation1, operation2, operation3, operation4, operation5]) {
  12.         switch(operation) {
  13.             case 'chop': start = chop(start);
  14.                 break;
  15.             case 'dice': start = dice(start);
  16.                 break;
  17.             case 'spice': start = spice(start);
  18.                 break;
  19.             case 'bake': start = bake(start);
  20.                 break;
  21.             case 'fillet': start = fillet(start);
  22.                 break;
  23.         }
  24.  
  25.         console.log(start);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement