Create a productOfTheOthers() function that takes in an array of integers and replaces each number in the array with the product of all the numbers in the array except the number at that index itself.

For example, productOfTheOthers([1, 2, 3, 4, 5]) should return [120, 60, 40, 30, 24] and productOfTheOthers([5, 5, 5]) should return [25, 25, 25].

This challenge was reported to have been asked at interviews with Google. If you’ve covered the material in Pass the Technical Interview with JavaScript or an equivalent, you should be able to solve this challenge. If you have trouble, try refreshing your knowledge with its Algorithmic Complexity content.