Mode entretien. Minuteur de 6 min, sans indices ni autocomplétion
Employees
FacileClasses6 min
Write a class Employee. The constructor new Employee(name, age, empId) stores the fields name, age and empId. The method info() returns a string like 'Ann, 30, id 101'.
Also write a function findEmployee(employees, empId). It looks for the employee with that empId in the array and returns it. If there is none, return null.
Exemples
new Employee('Ann', 30, 101).info()Renvoie 'Ann, 30, id 101'
findEmployee([new Employee('Ann', 30, 101), new Employee('Bob', 41, 102)], 102).info()Renvoie 'Bob, 41, id 102'
findEmployee([new Employee('Ann', 30, 101)], 7)Renvoie null
Posé chez Cognizant · Source
Chargement de l'éditeur...
- The constructor stores the fields
- info() format
- The search finds the employee
- No employee gives null
Les tests cachés se lancent à la soumission