Edit: forgot to convert the input to a number making all of the numbers that go through the function a string
// grabs the input, the number of horses, from the input tagconstcalculate=(horses=Number(document.querySelector("#horses").value))=>{//puts the answer into an empty divdocument.querySelector("#answer").innerHTML=horses!==parseInt(horses)?undefined:horses<4?horses:factorial(horses)/factorial(horses-3);}constfactorial=(n)=>{returnn?n*factorial(n-1):1;}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Good old factorials. I had fun with this one. Feel free to give advice if I can make my code better!
JS
CodePen
Edit: forgot to convert the input to a number making all of the numbers that go through the function a string