AreWe

SimpleCalculator

Jun 10th, 2020
987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. simpleCalculator = (num1, num2, operator) => {
  2.     let MyMath = {
  3.         multiply: (n1, n2) => n1 * n2,
  4.         divide: (n1, n2) => n1 / n2,
  5.         add: (n1, n2) => n1 + n2,
  6.         subtract: (n1, n2) => n1 - n2
  7.     };
  8.     console.log(MyMath[operator](num1, num2));
  9. };
Advertisement
Add Comment
Please, Sign In to add comment