Advertisement
Guest User

Cooking by Numbers

a guest
Sep 23rd, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cookingNums(input) {
  2.     let operations = {
  3.         chop : x => x / 2,
  4.         dice : x => Math.sqrt(x),
  5.         spice : x => x + 1,
  6.         bake : x => x * 3,
  7.         fillet : x => x - (0.2 * x)
  8.     }
  9.  
  10.     let number = Number(input[0]);
  11.     let commands = input.slice(1);
  12.  
  13.     for (let command of commands){
  14.         number = operations[command](number);
  15.         console.log(number)
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement