Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { employees } from './employees.js';
- // (1) first task
- const findEmployeesInPriceRange = (employees, obj = {}) => {
- if ('min' in obj && 'max' in obj) {
- return employees.filter((salary) => salary.salary <= obj.max && salary.salary >= obj.min)
- .map((salary) => salary.name);
- } else {
- if ('min' in obj) {
- return employees.filter((salary) => salary.salary >= obj.min)
- .map((salary) => salary.name);
- } else {
- if ('max' in obj) {
- return employees.filter((salary) => salary.salary <= obj.max)
- .map((salary) => salary.name);
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment