viligen

cookingNumbers

May 19th, 2022
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function myFunc(num, ...param) {
  2.     num = Number(num)
  3.     actions = {
  4.         chop: (num) => num / 2,
  5.         dice: (num) => Math.sqrt(num),
  6.         spice: (num) => ++num,
  7.         bake: (num) => num * 3,
  8.         fillet: (num) => num * 0.8
  9.     }
  10.  
  11.     while (param.length > 0){
  12.         command = param.shift()
  13.         num = actions[command](num)
  14.         console.log(num)
  15.     }
  16. }
  17.  
  18.  
  19.  
  20. myFunc('9', 'dice', 'spice', 'chop', 'bake', 'fillet')
Advertisement
Add Comment
Please, Sign In to add comment