Last active
February 19, 2018 19:44
-
-
Save AdrianSkar/58395caa903e5211dfd3d9303cf3811f to your computer and use it in GitHub Desktop.
freeCodeCamp exercise: JS factorialize a number
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 while loop | |
function factorialize(num) { | |
if (num == 0){ | |
return 1; | |
} | |
var result = 1; | |
while (num>0){ | |
result *= num; | |
num--; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment