Hi can anyone tell how to exactly use Flat or flatMap method to flat this employee data array, so that I can get the slaries which are less than 5000, with the name of the employees.
const employeeData = [{
name: "Suresh",
salary: 7500
}, {
name: "Aman",
salary: 3400
}, {
name: "Munish",
salary: 10000
}, {
name: "Chad",
salary: 12000
}, {
name: "Naveen",
salary: 9500
}];
const flattendEmpdata = employeeData.flat((name, salary) => [name, employeeData[salary]]);
I was trying to use Flat and filter method in chaining method, the desired ouput will be like this
{name: Suresh, salary: 7500} , {name: Aman, salary: 3400}