Ad
Code
Diff
  • function calculateEvenNumbers(array $numbers): int {
      return count(array_filter($numbers, function($num) { return $num % 2 === 0; }));
    }
    • function calculateEvenNumbers(array $numbers): int {
    • $count = 0;
    • foreach ($numbers as $number) {
    • if ($number % 2 === 0) {
    • $count++;
    • }
    • }
    • return $count;
    • return count(array_filter($numbers, function($num) { return $num % 2 === 0; }));
    • }