Using BigInt in JavaScript, write a factorial function that takes either a Number or BigInt and returns a BigInt
My answer is pretty heavily based on this resource on BigInt, so feel free to explore that a bit first.

With that said, here are some of the key points I saw:


BigInt can use all the same types of simple arithmetic as Number, along with 0 being considered falsy as usual


1n + 3n === 4n // true!



BigInt is also usable as a JS primitive. Neat!


typeof 1n === "bigint" // true!



BigInt and Number should not be mixed and matched. The coercion between the two is ambiguous, and as such JavaScript would throw an exception in that circumstance, so you should only either use one or the other.


1 + 1n // whoops



If the article still holds true, BigInt doesn't have the luxury of using operations in the built-in Math object. So you would either need to stick to simple arithmetic, or build (or otherwise find) those implementations yourself.
Since the supported operations on BigInt are not constant time (according to the article), it is recommended to use BigInt strictly when a use case will frequently involve numbers higher than the largest representable int in Number (253). Your question is one such case, since factorials grow extremely fast, so I think it's fine as is.