Skip to content

Commit 2c3e8e1

Browse files
authored
Update petsStartingWithH filter for case insensitivity
Refactor petsStartingWithH to handle case sensitivity.
1 parent 6599391 commit 2c3e8e1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sprint-3/3-dead-code/exercise-2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable.
33

44
const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
5-
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
6-
5+
const petsStartingWithH = pets.filter(
6+
(pet) => pet[0].toLowerCase() === "h"
7+
);
78

89
function countAndCapitalisePets(petsArr) {
910
const petCount = {};

0 commit comments

Comments
 (0)