Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a program that filters the employees of your company. You should print the result in a specific format. You will receive 2 parameters (data, criteria). You should parse the input, find all employees that fullfil the citeria and print them.
- Input
- You will receive a string with all the employees, and a criteria by witch you should sort the employees. If the criteria is "all" print all the employees in the given format.
- function solve(data, criteria) {
- let employees = JSON.parse(data);
- let [key, value] = criteria.split('-');
- employees.filter(employee => employee[key] == value || key == 'all')
- .forEach((employee, i) => {
- console.log(`${i}. ${employee.first_name} ${employee.last_name} - ${employee.email}`);
- });
- }
- solve(`[{
- "id": "1",
- "first_name": "Ardine",
- "last_name": "Bassam",
- "email": "abassam0@cnn.com",
- "gender": "Female"
- }, {
- "id": "2",
- "first_name": "Kizzee",
- "last_name": "Jost",
- "email": "kjost1@forbes.com",
- "gender": "Female"
- },
- {
- "id": "3",
- "first_name": "Evanne",
- "last_name": "Maldin",
- "email": "emaldin2@hostgator.com",
- "gender": "Male"
- }]`,
- 'gender-Female'
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement