JSFiddle - React, Tailwind, and code Playground

JavaScript

function add(){
    var sum = 0, x = 0;
    for(var i in arguments){
        //the key is an index
        if(!arguments.hasOwnProperty(i)) continue;
        
        // try converting argument[i] to a number
        x = +arguments[i];
        
        // check if argument is a valid number 
        if(!isNaN(x)) {
            sum += x;
        }
    }
    return sum;
}

console.log(add(1, 2, 3, 4, "5a", "a", 5, 4, 3, 2, 1));