SHARE
TWEET

03.Filter Employees

a guest Jan 24th, 2020 83 in 338 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(data, criteria) {
  2.   let parsed = JSON.parse(data);
  3.   let [criteriaName, criteriaValue] = criteria.split("-");
  4.  
  5.   let result = {};
  6.   let counter = 0;
  7.  
  8.   for(let item of parsed) {
  9.     let containsValue = item[criteriaName]
  10.     if (containsValue == criteriaValue) {
  11.         result[counter++] = `${item.first_name} ${item.last_name} - ${item.email}`;
  12.     }
  13.   }
  14.  
  15.   Object.entries(parsed).forEach(obj => {
  16.   });
  17.  
  18.   Object.entries(result).forEach(line => {
  19.     let num = line[0];
  20.     let valuesOfObject = line[1];
  21.  
  22.     console.log(
  23.       `${num}. ${valuesOfObject}`
  24.     );
  25.   });
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top