1.1. Classes as first-class objects: As you may recall, a class is basically a function that can be used with new. Therefore, it stands to reason that we should be able to pass classes as parameters to other functions. makeSaluteClass()Â creates a class (that is, a special function) that uses a closure to remember the value of term. We'll be looking at more examples like this throughout this book.
1.2. Factorial errors: The key to avoiding repeating tests is to write a function that will check the value of the argument to ensure it's valid, and if so call an inner function to do the factorial itself, without worrying about erroneous arguments:
const carefulFact = n => {
if (
typeof n !== "undefined" &&
Number(n) === n &&
n >= 0 &&
n === Math.floor(n...