Hi everyone, I'm looking for guidance on how to properly utilize the Flat or flatMap method to flatten this array of employee data. Specifically, I want to retrieve the names and salaries of employees whose salary is less than 5000.
const employeeData = [{
name: "Suresh",
salary: 7500
}, {
name: "Aman",
salary: 3400
}, {
name: "Munish",
salary: 10000
}, {
name: "Chad",
salary: 12000
}, {
name: "Naveen",
salary: 9500
}];
const flattenedEmpData = employeeData.flat((name, salary) => [name, employeeData[salary]]);
I attempted to use a combination of the Flat and filter methods in a chaining method. The expected result should look like this:
{name: Suresh, salary: 7500} , {name: Aman, salary: 3400}