Advertisement
kstoyanov

03. Filter Employees

Oct 8th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function filterEmployees(arr, arg) {
  2.   const input = JSON.parse(arr);
  3.   const [name, value] = arg.split('-');
  4.  
  5.   const filterResult = input.filter((empl) => empl[name] === value);
  6.  
  7.   filterResult.forEach((epml, index) => {
  8.     console.log(`${index}. ${epml.first_name} ${epml.last_name} - ${epml.email}`);
  9.   });
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement