Last active
February 19, 2018 20:28
-
-
Save AdrianSkar/fec95ba96baf4725426b4ddbcfcaf0e9 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
// Using a for loop and reduce(); not the simplest solution but succesful first attempt. | |
function factorialize(num) { | |
if (num == 0){ | |
return 1; | |
} | |
var arr = []; | |
for (i=num; i>0; i--){ | |
arr.push(i); | |
} | |
return arr.reduce(function(a,b){ | |
return a * b; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment