javascript filter map foreach
HTML
<p id="text">Text:</p>
JavaScript
var repoParamConcesFinali = [
{iditensEstudo: "XFX", price: 240.00, volume: 23341 },
{iditensEstudo: "TNZ", price: 160.00, volume: 16584 },
{iditensEstudo: "WTJ", price: 26.00, volume: 16584 },
{iditensEstudo: "ZIO", price: 149.00, volume: 78958 },
{iditensEstudo: "KMA", price: 16.00, volume: 59777 }
];
var repoItensEstudo = [
{iditensEstudo: "XFX", price: 240.00, volume: 23341 },
{iditensEstudo: "WTJ", price: 26.00, volume: 16584 },
{iditensEstudo: "ZIO", price: 149.00, volume: 78958 },
{iditensEstudo: "sdf", price: 240.00, volume: 23341 },
{iditensEstudo: "edc", price: 160.00, volume: 16584 },
{iditensEstudo: "ghy", price: 26.00, volume: 16584 },
{iditensEstudo: "wsx", price: 149.00, volume: 78958 },
{iditensEstudo: "edc", price: 240.00, volume: 23341 },
{iditensEstudo: "TNZ", price: 160.00, volume: 16584 },
{iditensEstudo: "tgb", price: 160.00, volume: 16584 },
{iditensEstudo: "yhn", price: 26.00, volume: 16584 },
{iditensEstudo: "ikm", price: 149.00, volume: 78958 },
{iditensEstudo: "olp", price: 16.00, volume: 59777 }
];
var repoItensEstudo =
repoItensEstudo.map((item) => {
repoParamConcesFinali.forEach(function(repo){
if(item.iditensEstudo == repo.iditensEstudo){
item.checked = true;
}
})
return item;
});
document.getElementById('text').innerHTML= JSON.stringify(repoItensEstudo);
/*
var repoItensEstudo =
repoItensEstudo.
filter(function(val) {
return val.iditensEstudo;
});
/* map(function(val) {
return val.iditensEstudo;
});
*/