From 8c7da050b01f3fd352cd6873a59b8565a30656e4 Mon Sep 17 00:00:00 2001 From: Shyam-Chen Date: Sun, 21 Jul 2024 15:52:32 +0800 Subject: [PATCH] 172nd Commit --- .../numberOfEmployeesWhoMetTarget.test.ts | 8 ++++++++ .../numberOfEmployeesWhoMetTarget.ts | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.test.ts create mode 100644 src/page-25/2798. Number of Employees Who Met the Target/numberOfEmployeesWhoMetTarget.ts 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; +};