Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to return a factorial in javascript

function factorial(n) {
    if (n == 1) {
        return 1;
    }
    return n * factorial(n - 1);
}
console.log(factorial(6));
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #return #factorial #javascript
ADD COMMENT
Topic
Name
9+6 =