Created
July 13, 2017 16:56
-
-
Save junjunparkpark/40cfd74abfd3a80a79d2c81660625d4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var productExceptSelf = function(nums) { | |
let results = []; | |
nums.forEach((num, i) => { | |
let product = nums.reduce((acc, val, j) => i === j ? acc : acc *= val ); | |
results.push(product); | |
}) | |
return results; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment