Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save junjunparkpark/40cfd74abfd3a80a79d2c81660625d4d to your computer and use it in GitHub Desktop.
Save junjunparkpark/40cfd74abfd3a80a79d2c81660625d4d to your computer and use it in GitHub Desktop.
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