Repository navigation
London | 26-ITP-Sep | Mandip Sanger | Sprint 3 | Dead code #1764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
28385eb
533f258
e948c20
5c69310
b1e438e
d22a09c
f608dfa
058c015
d16106c
d782ddb
3383acf
aef6843
a455744
03c4cd0
3c0f2af
bb2ad3d
43d8c52
4125a13
8aaca21
067d162
4eb1b5a
4f1722c
3e73332
9276589
d8c1438
b573067
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,6 @@ | ||
| // Remove the unused code that does not contribute to the final console log | ||
| // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. | ||
|
|
||
| const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; | ||
| const capitalisedPets = pets.map((pet) => pet.toUpperCase()); | ||
| const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work! You've made good use of The solution is clear, readable and produces the expected output. Keep up the good work! |
||
|
|
||
| function logPets(petsArr) { | ||
| petsArr.forEach((pet) => console.log(pet)); | ||
| } | ||
|
|
||
| function countAndCapitalisePets(petsArr) { | ||
| const petCount = {}; | ||
|
|
||
|
|
@@ -25,4 +17,4 @@ function countAndCapitalisePets(petsArr) { | |
|
|
||
| const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); | ||
|
|
||
| console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log | ||
| console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! The function is reusable and correctly uses parameters rather than relying on hardcoded values. You've also kept the code simple and readable. I can't see any unreachable or redundant code that needs removing. Keep it up!