Digginit Digginit - 1 month ago 8
Javascript Question

How can i display array values, only if the number i greater than 50000? javascript

In income-greather-than-500k.html you will find an array of tax forms assigned to the variable
called taxForms .
In its current state the entire array is logged to the console. You need to

change the Javascript such that
only the real name of the superheroes that have an income greater than 500 000 are logged with
console.log .


This is the taxform:

const taxForms = [
{
realName: "Bruce Wayne",
income: 750000,
wealth: 300000
},
{
realName: "John Blake",
income: 440000,
wealth: 832000
},
{
realName: "Selina Kyle",
income: 640000,
wealth: 432000
}
];

Answer

You can use filter.

taxForms.filter(function(s) { return s.income > 500000 }).forEach(function (s) { console.log(s.realName) });