Skip to content

Conversation

@wankoak
Copy link

@wankoak wankoak commented Nov 12, 2025

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

Changelist

Completed Sprint 2 Implement tasks (contains, lookup, tally, querystring) with passing tests

No question

@wankoak wankoak added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 12, 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.

Can you check if any of this general feedback can help you further improve your code?
https://github.com/CodeYourFuture/Module-Data-Groups/blob/general-review-feedback/Sprint-2/feedback.md

Doing so can help reviewers speed up the review process. Thanks.


Why not practice committing files one by one? Making small commits has the following advantages:

  • Clarity: Each commit tells a clear story (one feature, one fix, one change).
  • Debugging: Easy to find and undo the commit that caused a bug.
  • Collaboration: Teammates can review and understand changes faster.
  • History: Project log becomes a readable timeline, not a messy dump.
  • Safety: Progress is saved in safe, logical steps—less risk of losing work.

If you would like to practice committing files one by one in VSCode, you can select which file to stage and then commit only the staged file.
See: this video (at around the 12:50 mark, it shows how to stage a single file).

@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 Nov 21, 2025
@wankoak
Copy link
Author

wankoak commented Nov 21, 2025

@cjyuan thanks a lot, I'll commit 1 by 1 next time. You didn't mention anything like fixing my code or any thing though and you didn't mark my PR complete which I assume there has to be something to fix

@cjyuan
Copy link
Contributor

cjyuan commented Nov 21, 2025

Have you checked out the General feedback link I shared in my previous comment?

@wankoak
Copy link
Author

wankoak commented Nov 21, 2025

@cjyuan yes i did and i found more helpful information, thanks

@wankoak wankoak 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 Nov 21, 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 looks great. Changes are optional.

If you would like me to review any new change, just comment or tag me on this PR.

Comment on lines +4 to +6
for (const pair of countryCurrencyPairs) {
const countryCode = pair[0];
const currencyCode = pair[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also use array destructuring to shorten the code on lines 4-6 (if you have time).

Copy link
Author

Choose a reason for hiding this comment

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

Yes you're right

Comment on lines +3 to +26

if (!queryString || queryString.length === 0) {
return queryParams;
}

// Remove leading '?' if present
if (queryString.startsWith("?")) {
queryString = queryString.substring(1);
}

const keyValuePairs = queryString.split("&");

for (const pair of keyValuePairs) {
const [key, value] = pair.split("=");
queryParams[key] = value;
// Only split on the first '=' to handle values containing '='
const equalsIndex = pair.indexOf("=");
if (equalsIndex === -1) {
// Handle keys without values
const key = decodeURIComponent(pair);
queryParams[key] = "";
} else {
const key = decodeURIComponent(pair.substring(0, equalsIndex));
const value = decodeURIComponent(pair.substring(equalsIndex + 1));
queryParams[key] = value;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This work great!
In practice, you can consider using a JS built-in function to parse query string.

// Use Object.create(null) to avoid inherited properties
const wordCounts = Object.create(null);

if (!str || str.trim() === "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Between (typeof str != "string" || str.trim() === "") and your current condition, which one do you think is better, and why?

@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 Nov 21, 2025
Comment on lines +40 to +61
// Split into words and handle punctuation/case
const words = str.split(/\s+/);

for (const word of words) {
// Remove punctuation and convert to lowercase
const cleanWord = word
.toLowerCase()
.replace(/[.,!?]/g, "")
.trim();

// Skip empty strings
if (cleanWord === "") continue;

// Count the word
if (wordCounts[cleanWord]) {
wordCounts[cleanWord] += 1;
} else {
wordCounts[cleanWord] = 1;
}
}

return wordCounts;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you do some pre-processing on str before line 41, you could simplify the code within the loop by about 50% (or more).

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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants