JSFiddle - React, Tailwind, and code Playground

by RichardBender

JavaScript

function numbers () {
    // Convert the arguments to an array
    var args = Array.prototype.slice.call(arguments);
    // Return false for no arguments, otherwise check if all are numbers.
    return args.length > 0 && args.reduce(function (previous, current) {
        return previous && typeof current === 'number';
    }, true);
}

// Test #1
console.log(numbers(1,2,3,4));

// Test #2
console.log(numbers(1, 2, "a", 4));

// Test #3
console.log(numbers());

// Test #4
console.log(numbers(1,2,3,NaN));

// Test #5
console.log(numbers(1,"2",3,"4"));