daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interpret(1, ["+"], [1]) → 2
  2.  
  3. interpret(4, ["-"], [2]) → 2
  4.  
  5. interpret(1, ["+", "*"], [1, 3]) → 6
  6.  
  7. interpret(5, ["+", "*", "-"], [4, 1, 3]) → 6
  8.      
  9. function interpret(num, arr2, arr3) {
  10.     for(var i = 0; i < arr2.length; i++){
  11.         if(arr2[i]== "+" && arr2.length === 1) return num + Number(arr3[i]);
  12.         if(arr2[i]== "-" && arr2.length === 1) return num - Number(arr3[i]);
  13.         if(arr2[i]== "*" && arr2.length === 1) return num * Number(arr3[i]);
  14.     }
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top