Sobes.tech
Intern — Middle

Determining the username with the highest salary among people younger than a specified age

livecode

Task condition

It is necessary to write a function that takes an age limit as an argument and returns the name of the employee with the highest salary, provided that their age is less than the specified threshold.

const people = [
  { id: 1, age: 16, salary: 200, name: 'Andrey', roles: ['front'] },
  { id: 2, age: 21, salary: 250, name: 'Vasya', roles: ['back'] },
  { id: 3, age: 30, salary: 400, name: 'Sergey', roles: ['front', 'lead'] },
  { id: 4, age: 25, salary: 360, name: 'Dmitriy', roles: ['manager'] },
  { id: 5, age: 50, salary: 420, name: 'Max', roles: ['back', 'lead'] },
];