Skip to content

Conversation

mayowa0-7
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@mayowa0-7 mayowa0-7 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 22, 2025
@mayowa0-7 mayowa0-7 changed the title Module data sprint 2 Sheffield| May 2025| Mayowa Fadare|Module data sprint 2 Jul 22, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

  • Code is pretty solid. Good job.

  • stretch/count-words.js and till.js were not fully implemented. So I didn't leave any comment to them.

Comment on lines 2 to 14
function tally(items) {
if (!Array.isArray(items)) {
throw new Error("Input must be an array");
}
const counts = {};
for (const item of items) {
if (typeof item !== "string" && typeof item !== "number") {
throw new Error("Items must be strings or numbers");
}
counts[item] = (counts[item] || 0) + 1;
}
return counts;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Can you improve the indentation of this code?

  • Can you check if your function returns what you expect from the following function call?

  tally(["toString", "toString", "toString"]); 

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the review, code now well indented and function call updated. ✅

@cjyuan cjyuan 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 Jul 26, 2025
@mayowa0-7 mayowa0-7 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jul 30, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

The code in tally.js is not working properly after change.

@@ -1,16 +1,16 @@

function tally(items) {
function tally(["toString", "toString", "toString"]); {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this code even run? My previous comment was

Can you check if your function returns what you expect from the following function call?
tally(["toString", "toString", "toString"]);

Copy link
Author

Choose a reason for hiding this comment

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

No it doesn't, but I have effected it with the correct function

@cjyuan cjyuan 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 Aug 1, 2025
@mayowa0-7 mayowa0-7 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 2, 2025
Comment on lines 6 to 12
const counts = {};
for (const item of items) {
if (typeof item !== "string" && typeof item !== "number") {
throw new Error("Items must be strings or numbers");
}
counts[item] = (counts[item] || 0) + 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the following function call returns the value you expect?

tally(["toString", "toString"]);

Suggestion: Look up an approach to create an empty object with no inherited properties.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complete Volunteer to add when work is complete and all review comments have been addressed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants