JSFiddle - React, Tailwind, and code Playground
HTML
Fast input: <input type="text" />
<br>
Slow input: <input type="text" id="input" />
JavaScript
var factorial = function(n) {
if(n == 0) {
return 1
} else {
product = 1;
for(i = 1; i <= n; i++) {
product *= i;
}
return product;
}
};
var input = document.getElementById('input')
input.addEventListener('keydown', function(event) {
console.log(factorial(100000000));
});