My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Array Problem In Javascript

Default profile photo
Anonymous
·Mar 22, 2018

given an array of integers, return an output array such that output[i] is equal to the product of all the elements in the array other than itself

for example :

var firstArray = [2, 2, 4, 1]; // o/p: [8, 8, 4, 16] var secondArray = [0, 0, 0, 2];o/p: [0, 0,0,0] var thirdArray = [-2, -2, -3, 2]; 0/P: [12, 12, 8, -12]

What should be the approach for this kind of problem?