Advertisement
kstoyanov

03. Filter Employees v2

Oct 8th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr, test) {
  2.   const input = JSON.parse(arr);
  3.   const [name, value] = test.split('-');
  4.  
  5.   const filterResult = [];
  6.   for (let i = 0; i < input.length; i++) {
  7.     if (input[i][name] === value) {
  8.       filterResult.push(input[i]);
  9.     }
  10.   }
  11.    
  12.   filterResult.forEach((epml, index) => {
  13.     console.log(`${index}. ${epml.first_name} ${epml.last_name} - ${epml.email}`);
  14.   });
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement