Tail Call

Open Console to see the results.

If your browser supports proper tail calls, this example works.

"use strict";
function fact(n, acc) {
  if (n === 0) {
    return acc;
  }
  return fact(n - 1, n * acc);
}