serdarshefketov

a

Jan 24th, 2022
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { employees } from './employees.js';
  2.  
  3.  
  4. // (1)  first task
  5. const findEmployeesInPriceRange = (employees, obj = {}) => {
  6.  
  7.     if ('min' in obj && 'max' in obj) {
  8.         return employees.filter((salary) => salary.salary <= obj.max && salary.salary >= obj.min)
  9.             .map((salary) => salary.name);
  10.     } else {
  11.  
  12.         if ('min' in obj) {
  13.             return employees.filter((salary) => salary.salary >= obj.min)
  14.                 .map((salary) => salary.name);
  15.  
  16.         } else {
  17.  
  18.             if ('max' in obj) {
  19.                 return employees.filter((salary) => salary.salary <= obj.max)
  20.                     .map((salary) => salary.name);
  21.             }
  22.         }
  23.     }
  24. };
Advertisement
Add Comment
Please, Sign In to add comment