Advertisement
Militsa

03. Multiply / Divide a Number

Dec 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function multiplyOrDivide(arr) {
  2.     let num1 = Number(arr[0]);
  3.     let num2 = Number(arr[1]);
  4.  
  5.     if (num1 > num2) {
  6.         console.log(num1 / num2);
  7.     }
  8.     else {
  9.         console.log(num1 * num2);
  10.     }
  11. }
  12.  
  13. //multiplyOrDivide(['6', '3']); 6 / 3 = 2
  14. //multiplyOrDivide(['2', '3']); 2 * 3 = 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement