Skip to content

London | 26-ITP-Sep | Mars Adesina | Sprint 3 | Refactoring Dead Code - #1745

Open
marscancode wants to merge 2 commits into
CodeYourFuture:mainfrom
marscancode:coursework/sprint-3-dead-code
Open

marscancode wants to merge 2 commits into
CodeYourFuture:mainfrom
marscancode:coursework/sprint-3-dead-code

Conversation

@marscancode

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

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.

@marscancode marscancode added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module labels Oct 21, 2026

@iscmiguelsamaniego iscmiguelsamaniego left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread dead-code/exercise-1.js Resolved
Comment thread dead-code/exercise-2.js

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@marscancode marscancode added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 23, 2026

@dkrest1 dkrest1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread dead-code/exercise-2.js
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread dead-code/exercise-2.js

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 dkrest1 added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants