As you use Number.isInteger() , you'll miss float numbers. You can use typeof / Object.prototype.toString.call() to detect number:
Number.isInteger(0.1) // false typeof 0.1 === "number" // true Object.prototype.toString.call(0.1) ==="[object Number]" // true
And , here another solution:
const addTogether = ( a, ...arr ) => typeof a !== "number" ? undefined : arr.length === 0 ? addT( a ) : addT( a )( arr[0] ) const addT = a => b => typeof b !== "number" ? undefined : a + b
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
As you use Number.isInteger() , you'll miss float numbers.
You can use typeof / Object.prototype.toString.call() to detect number:
And , here another solution: