Naïve JavaScript factorial

In order of decreasing performance:

An iterative factorial function with an accumulator variable

function factorial(n) {
    assert(Number.isInteger(n) && n >= 0,
        `I wanted a non-negative integer argument, got ${n}.`)

    let a = 1
    while (n >= 2) {
        a *= n
        --n
    }
    return a
}

A recursive factorial function

function recursiveFactorial(n) {
    assert(Number.isInteger(n) && n >= 0,
        `I wanted a non-negative integer argument, got ${n}.`)

    if (n < 2) return 1

    return n * recursiveFactorial(n - 1)
}