Last active
May 2, 2021 22:52
-
-
Save osahondev/109185d053f986cea0587d7092006e6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const productsArray = nums =>{ | |
| if( nums == undefined || nums == null ) return []; | |
| if( !Array.isArray(nums) ) return []; | |
| if( nums.length == 0 ) return []; | |
| if( nums.length == 1 ) return[0]; | |
| let product = 1; | |
| for(let [index,number] of nums.entries()){ | |
| product = number * product; | |
| } | |
| for( let [j,number] of nums.entries() ){ | |
| nums[j] = product/number; | |
| } | |
| return nums; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @meekg33k, thank you for your feedback as always.
Please find below my comments.
I have made two changes to the function.
I would be happy to know your thought about this approach.