Count Tested Devices After Test Operations

EasyArraySimulationCounting

Solution

export function countTestedDevices(batteryPercentages: number[]): number {
  let testedDevice = 0;
  for (const batteryPercentage of batteryPercentages) {
    if (testedDevice < batteryPercentage) {
      testedDevice += 1;
    }
  }
  return testedDevice;
}