Repository navigation
London | 26-ITP-Sep | Mars Adesina | Sprint 3 | Refactoring Dead Code - #1745
marscancode wants to merge 2 commits into
Conversation
iscmiguelsamaniego
left a comment
There was a problem hiding this comment.
Excellent work overall! All previous exercises and tests are clean, accurate, and well-implemented. For the final exercise, please review the duplicate variable declaration and complete the frequency map logic for countAndCapitalisePets. Great progress so far!
There was a problem hiding this comment.
Excellent work start on structuring the function and array operations.
Quick question:
countedPetsStartingWithH is declared twice, and the function currently returns an empty object. How might you iterate through the array to populate the frequency map?
There was a problem hiding this comment.
Hi , Thanks for reviewing my work. I'm a little unsure about your feedback regarding the duplicate declaration and the empty object. I moved the countedPetsStartingWithH declaration rather than keeping both declarations, and my function already had the .forEach() loop to populate petCount. When I run my current code, it returns { HAMSTER: 3, HORSE: 1 }. Could you clarify what I need to change or which part I may have misunderstood? Thanks!
There was a problem hiding this comment.
Hi @marscancode
Just following up on your question from the earlier review.
I've checked the code currently shown in this PR, and countAndCapitalisePets() appears to initialise petCount as an empty object and return it without populating it.
You mentioned having a .forEach() loop that produces { HAMSTER: 3, HORSE: 1 }, but I can't see that loop in the version currently available here.
Could you check whether your latest changes have been committed and pushed to this branch?
That might explain the difference between what you're seeing locally and what's showing in the PR.
Thanks for following up on the feedback!
dkrest1
left a comment
There was a problem hiding this comment.
Great work on the Dead Code exercises!
Exercise 1 looks good. You've simplified sayHello() while preserving its intended behaviour.
For Exercise 2, there's just one issue to revisit: the function currently returns an empty object rather than the expected pet counts.
I've left an inline comment with more details. Please check that your latest implementation has been pushed and that the function produces the expected output.
Thanks for engaging thoughtfully with the previous feedback. You're making good progress!
| const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); | ||
|
|
||
| function countAndCapitalisePets(petsArr) { | ||
| const petCount = {}; |
There was a problem hiding this comment.
Hi Mars! 👋
Thanks for clarifying your approach in the earlier discussion.
Looking at the current version of exercise-2.js, I can see that petCount is initialised as an empty object and returned without being populated.
You mentioned using .forEach() to count the pets, but I couldn't find that loop in the current code.
Could you double-check whether your latest changes have been committed and pushed to this PR?
The expected output is { HAMSTER: 3, HORSE: 1 }, but the current implementation appears to return {}.
Keep up the good work!
There was a problem hiding this comment.
Hi @marscancode
Just following up on your question from the earlier review.
I've checked the code currently shown in this PR, and countAndCapitalisePets() appears to initialise petCount as an empty object and return it without populating it.
You mentioned having a .forEach() loop that produces { HAMSTER: 3, HORSE: 1 }, but I can't see that loop in the version currently available here.
Could you check whether your latest changes have been committed and pushed to this branch?
That might explain the difference between what you're seeing locally and what's showing in the PR.
Thanks for following up on the feedback!
Learners, PR Template
Self checklist
Task code
CYF-1066
Changelist
Refactored the code to remove any unused code that was not contributing to the final function output for sayHello and countAndCapitalisePets and ran the code to check that the final output matched the intended output.