I got an array like this:
const xx = [
{
name: "Alex",
income: 324300,
total: 3030000
},
{
name: "Snake",
income: 3433000,
total: 34323000
}
];
I want to check if the income is larger than 300000 and if it is then their name would be stored or logged.
This is what i have tried, i dont fully understand how it works so..
var f = {};
for (var i = 0, len = xx.length; i < len; i++) {
f[xx[i].id] = xx[i];
if(f[income]>=500000){
console.log(xx[i]);
}
}
ffor? Your objects have no.idproperty, sof[xx[i].id] = xx[i]doesn't make much sense. Did you meanf[xx[i].name]? There's noincomevariable, sof[income]doesn't make sense, though there is anincomeproperty on eachxx[i]object, so did you meanxx[i].incomeorf[xx[i].name].income?