Hey thanks for your quick reply… So it is not possible to just output a particular array index ( say Jobrole in this example ) using only map right ? map only returns the whole array as a new array modified or unmodified… correct me if I’m wrong…
Now, here I’m creating a function where you pass:
the info you want to get (name, jobrole, salary, dob)
the search criteria you’d like to look for (name, jobrole, salary, dob)
the value that you are looking to match (ex. “Clerk”)
And it returns your search in an array
function searchEmployees(search, criteria, value) {
let arr = [];
employees.forEach(function(a){
if (a[criteria] == value) {
arr.push(a[search]);
}
});
return arr;
}
You could now try:
searchEmployees ("name", "jobrole", "Clerk"); // Gets all names whose jobrole is 'Clerk'
searchEmployees ("salary", "jobrole", "Officer"); // Gets the salaries of the Officers
searchEmployees ("dob", "salary", "$200"); // Gets dob of people who make $200