diff --git a/src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.test.ts b/src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.test.ts new file mode 100644 index 0000000..3c5844a --- /dev/null +++ b/src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.test.ts @@ -0,0 +1,8 @@ +import { numberOfEmployeesWhoMetTarget } from './numberOfEmployeesWhoMetTarget'; + +describe('2798. Number of Employees Who Met the Target', () => { + test('numberOfEmployeesWhoMetTarget', () => { + expect(numberOfEmployeesWhoMetTarget([0, 1, 2, 3, 4], 2)).toBe(3); + expect(numberOfEmployeesWhoMetTarget([5, 1, 4, 2, 2], 6)).toBe(0); + }); +}); diff --git a/src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.ts b/src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.ts new file mode 100644 index 0000000..8af88ff --- /dev/null +++ b/src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.ts @@ -0,0 +1,8 @@ +type numberOfEmployeesWhoMetTarget = (hours: number[], target: number) => number; + +/** + * Accepted + */ +export const numberOfEmployeesWhoMetTarget: numberOfEmployeesWhoMetTarget = (hours, target) => { + return hours.filter((hour) => hour >= target).length; +};