Skip to content

LONDON | 25-ITP-MAY | TEWODROS BEKERE | M-D-G | SPRINT-2 #674

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

iteddy16
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.

  • Finished all sprint-2 tasks.

Questions

Ask any questions you have for your reviewer.

@iteddy16 iteddy16 changed the title LONDON | 25-ITP-MAY | TEWODROS BEKERE | M.D.G/Sprint-2 LONDON | 25-ITP-MAY | TEWODROS BEKERE | M.D.G | SPRINT 2 Jul 22, 2025
@iteddy16 iteddy16 added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Participant to add when requesting review labels Jul 22, 2025
@iteddy16 iteddy16 changed the title LONDON | 25-ITP-MAY | TEWODROS BEKERE | M.D.G | SPRINT 2 LONDON | 25-ITP-MAY | TEWODROS BEKERE | M.D.G | SPRINT-2 Jul 22, 2025
@iteddy16 iteddy16 changed the title LONDON | 25-ITP-MAY | TEWODROS BEKERE | M.D.G | SPRINT-2 LONDON | 25-ITP-MAY | TEWODROS BEKERE | M-D-G | SPRINT-2 Jul 22, 2025
@a-robson a-robson added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jul 25, 2025
Copy link

@a-robson a-robson left a comment

Choose a reason for hiding this comment

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

Overall this is very good. You're making great progress. I've made some comments and suggestions.

Comment on lines 8 to 10
const keyValuePairs = queryString.split("&");

for (const pair of keyValuePairs) {

Choose a reason for hiding this comment

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

How will code cope with invalid input like &name=Zadie& or city=London&&year=2025?

Comment on lines +16 to +19
key = decodeURIComponent(pair.substring(0, index));
value = decodeURIComponent(pair.substring(index + 1));
} else {
key = decodeURIComponent(pair);

Choose a reason for hiding this comment

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

What will happen if string passed to decodeURIComponent is not a well-formed URI?

Comment on lines +7 to +11
if (obj.hasOwnProperty(key)) {
return true;
} else {
return false;
}

Choose a reason for hiding this comment

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

Do we need an if/else here? How could we simplify this?

Comment on lines +1 to +18
function tally(items) {
if (!Array.isArray(items)) {
throw new Error("Input must be an array");
}

const counts = {};

for (let i = 0; i < items.length; i++) {
const item = items[i];
if (counts[item]) {
counts[item]++;
} else {
counts[item] = 1;
}
}

return counts;
}

Choose a reason for hiding this comment

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

Your current solution works well! For future reference, this is a common use case for the reduce() method, which is designed specifically for accumulating values from arrays. If you're interested in exploring an alternative approach, reduce() could make this more concise.

No changes needed—just something to keep in mind for similar problems.

Comment on lines +3 to +4
const { test } = require("picomatch");

Choose a reason for hiding this comment

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

Solution is good and explanations are clear. However I'm not sure why you are importing picomatch. Please put your tests in a separate file - invert.test.js

@a-robson a-robson added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review 📅 Sprint 2 Assigned during Sprint 2 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants