{"size": 833, "ext": "js", "max_stars_repo_path": "javascript/Javascript Funcional/filter-3.js", "max_stars_repo_name": "PedroPadilhaPortella/Curso_Desenvolvimento_Web_JavaScript_Cod3r", "max_stars_repo_stars_event_min_datetime": "2020-06-10T23:23:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-10T23:23:32.000Z", "max_issues_repo_path": "javascript/Javascript Funcional/filter-3.js", "max_issues_repo_name": "PedroPadilhaPortella/Curso_Desenvolvimento_Web_JavaScript", "max_issues_repo_issues_event_min_datetime": "2020-10-30T22:17:39.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-01T19:53:09.000Z", "max_forks_repo_path": "javascript/Javascript Funcional/filter-3.js", "max_forks_repo_name": "PedroPadilhaPortella/Curso_Desenvolvimento_Web_JavaScript_Cod3r", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 20, "max_forks_count": null, "avg_line_length": 33.32, "max_line_length": 99, "alphanum_fraction": 0.6254501801}
Array.prototype.portellaFilter = function(fn) {
    const filtered = []
    for (let i = 0; i < this.length; i++) {
        if(fn(this[i], i, this)) {
            filtered.push(this[i])
        }
    }
    return filtered;
}

const impostos = [
    { nome: 'Rendimentos',  total: 30000, tributavel: false },
    { nome: 'Salário', total: 50000, tributavel: true },
    { nome: 'Renda Fixa', total: 12000, tributavel: true },
    { nome: 'Renda Variável', total: 80000, tributavel: true },
    { nome: 'Freelance', total: 18000, tributavel: false },
]

const imposto = impostos.portellaFilter(imposto => imposto.tributavel && imposto.total > 30000)
const total = imposto.map(el => el.total).reduce((total, subtotal) => total += subtotal, 0) * 0.01;

console.log("IMPOSTO DE RENDA")
console.log(imposto)
console.log(`TOTAL: ${total}`)
