{"size": 1046, "ext": "js", "max_stars_repo_path": "challenge01_questions/expenses.js", "max_stars_repo_name": "RuthMaria/bootcamp-launchBase", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "challenge01_questions/expenses.js", "max_issues_repo_name": "RuthMaria/bootcamp-launchBase", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "challenge01_questions/expenses.js", "max_forks_repo_name": "RuthMaria/bootcamp-launchBase", "max_forks_repo_forks_event_min_datetime": "2020-07-28T16:31:07.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-27T13:53:37.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 20.5098039216, "max_line_length": 94, "alphanum_fraction": 0.5564053537}

const users = [
    {
      name: "Salvio",
      revenue: [115.3, 48.7, 98.3, 14.5],
      expenses: [85.3, 13.5, 19.9]
    },
    {
      name: "Marcio",
      revenue: [24.6, 214.3, 45.3],
      expenses: [185.3, 12.1, 120.0]
    },
    {
      name: "Lucia",
      revenue: [9.8, 120.3, 340.2, 45.3],
      expenses: [450.2, 29.9]
    }
]


function usersExpenses(){

    for (const user of users) {
        const balance = calculateBalance(user.revenue, user.expenses)

        if (balance > 0) {
            console.log(`${user.name} has balance POSITIVE of the ${balance.toFixed(2)}`)     

        } else {
            console.log(`${user.name} has balance NEGATIVE of the ${balance.toFixed(2)}`)
        }
    }
}

function calculateBalance(revenue, expenses) {
    const sumRevenue = sumNumbers(revenue) 
    const sumExpenses = sumNumbers(expenses)
    return sumRevenue - sumExpenses
}

function sumNumbers(numbers) {
    let sum = 0

    for (const number of numbers) {
        sum += number
    }

    return sum
}

usersExpenses()