JSFiddle - React, Tailwind, and code Playground

by gregbabula

HTML

<!--

"Create a module with one private and one public method, the public method can accept any number of arguments. It must disregard any arguments that are not an integer. This method must rely on a private method to calculate the sum of these integers"

-->

JavaScript

var MyModule = (function() {
    function calculateSum() {
        var total = 0,
            args = arguments[0],
            argLength = args.length;
        
        for (var i = 0; i < argLength; i++) {
            if (typeof args[i] === "number") {
                total += args[i];
            }
        }
        
        console.log(total);
    };
    
    function getSum() {
        calculateSum(arguments);
    };
    
    return {
        getSum: getSum
    }
}());


// calculate
MyModule.getSum(5, 10, 'x', 'd', 2);