Last active
December 24, 2019 21:08
-
-
Save jbmilgrom/22bfdc2d2b22dc80f892b1830928f08a to your computer and use it in GitHub Desktop.
This file contains 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 factorial = n => { | |
let total = 1; | |
while (n > 0) { | |
total = total * n; | |
n = n - 1; | |
} | |
return total; | |
}; | |
factorial(0); // => 1 | |
factorial(1); // => 1 | |
factorial(2); // => 2 | |
factorial(3); // => 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment