JenMorgan / js-learning

0 stars 0 forks source link

JS function to calculate the salary of all the employees in the object #38

Open JenMorgan opened 4 years ago

JenMorgan commented 4 years ago
function ifEmpty (obj) {
    for (let key in obj) {
        return false;
    }
    return true;
};

function salariesSum (obj) {
    if (ifEmpty(obj)) return 0;
    let salary = 0;
    for (let key in obj) {
        salary += obj[key];
    }
    return salary;
};