Skip to content

London | 26-ITP-Sep | Maharit Belai | Sprint 2 | coursework/sprint-2 - #1512

Open
MaharitB wants to merge 53 commits into
CodeYourFuture:mainfrom
MaharitB:coursework/sprint-2
Open

MaharitB wants to merge 53 commits into
CodeYourFuture:mainfrom
MaharitB:coursework/sprint-2

Conversation

@MaharitB

@MaharitB MaharitB commented Nov 11, 2026 •

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-1083

Changelist

I have done all the course work and created new file for the Invert.js ans have pushed it along with the rest of file

Questions

@github-actions

This comment has been minimized.

@MaharitB MaharitB added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 11, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 11, 2026
@MaharitB MaharitB added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 11, 2026
@hey-hammad hey-hammad added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 11, 2026
@Stephanieewelu

Copy link
Copy Markdown

Thanks for the PR! You've made good progress and added some solid test coverage, but there are a few correctness and contract issues that need to be addressed before we can merge.

Below are the main issues to look into:

Sprint-2/implement/lookup.js:

Bullet The function currently ignores the input array and hardcodes a fixed mapping instead of dynamically building the lookup from the provided data.
Bullet This causes it to fail for cases outside the hardcoded values and violates the expected contract of createLookup(array).
Sprint-2/implement/querystring.js
Bullet Using replace("+", " ") only replaces the first + in each key/value rather than all occurrences. This means values like "first+name=Mary+Jane" are not being decoded correctly.
Bullet It currently overwrites duplicate keys instead of safely handling repeated parameters.

Sprint-2/implement/tally.js:

Bullet There is a typo in the thrown error string: "tally rquires an input". The task contract expects an error matching "tally requires an array", so the exact message will likely fail tests as-is.

@hey-hammad hey-hammad 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.

Good effort overall, however few areas need attention. Thanks

Comment thread Sprint-2/debug/address.js Outdated
@@ -1,5 +1,7 @@
// Predict and explain first...

// my prediction is that this is not indexed array. it is an array that uses key.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

whats the difference between an array and an object in javascript?

can address be called an array?

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.

The difference is that array uses index and object uses key to access their values. Address is object

Comment thread Sprint-2/debug/author.js
// Predict and explain first...

// my prediction here is that we can not use for..of loop because author is not iterable.
// The reason is, it doesnt use indices it uses keys.instead we will use for..in loop.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Its true that author is not iterable.

however the reason for that isn't that it uses keys instead. More on this in the following article.

https://medium.com/@mohammedelaouri/understanding-why-objects-are-not-iterable-in-javascript-and-the-best-ways-to-iterate-over-them-5048f8edf5d8

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.

Thank you for the article! It is insightful.

Comment thread Sprint-2/implement/lookup.js Outdated
function createLookup() {
// implementation here
function createLookup(array) {
const currency = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

please review the function spec again in lookup.test.js. you're not supposed to hardcode the country codes rather when given them in nested return them in an object.

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.

I guess I misunderstood what it was asking, took currency as pre-given data and tried to look what the test provided and match. Now I will change the whole approach. Thank you for pointing that out.

Comment thread Sprint-2/implement/querystring.test.js Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

please delete this since you're not working on this optional case.

@@ -1,15 +1,30 @@
function parseQueryString(queryString) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what happens when you pass the following input to the fn?

parseQueryString("a+b+c=x+y+z")

is this the correct output?

Comment thread Sprint-2/interpret/invert.test.js Outdated
expect(invert({})).toEqual({});
});
//test for one proprty in an object
test(" should return an empty object if given empty object", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

test description should match its logic.

Comment thread Sprint-2/interpret/invert.test.js Outdated
expect(invert({ a: 1 })).toEqual({ 1: "a" });
});
//test for two property in an object
test(" should return an empty object if given empty object", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

test description should match its logic.

@hey-hammad hey-hammad added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Nov 11, 2026
@MaharitB MaharitB 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 14, 2026
Comment thread Sprint-2/implement/querystring.js Outdated
let [key, ...rest] = pair.split("=");
let value = rest.join("=");

const lastThreeCharKey = key.slice(-3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is there reason for slicing the last 3 letter word?

are we certain that the key will always contain a 3 character second word?

what if we pass the following input the fn?

parseQueryString("name=John+Doe+Foo&age=30&city=New+York")

is the output correct?

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.

I have changed it to -2, and why I chose to that because I wanted to differentiate between an equation that hasn't been decoded and a word.
The out put was not correct. Only the first "+" sign was changed. so I made the changes to replace all .

Comment thread Sprint-2/implement/querystring.js Outdated

const lastThreeCharKey = key.slice(-3);
if (!lastThreeCharKey.includes("+") || key.includes("%")) {
key = decodeURIComponent(key.replace("+", " "));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

using a replace will only replace the first occurrence of "+", what if there are more than one occurrences.

is there another fn that replaces all the occurrences of a char?

@hey-hammad hey-hammad 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 14, 2026
@MaharitB MaharitB 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 14, 2026

const lastThreeCharKey = key.slice(-2);
if (!lastThreeCharKey.includes("+") || key.includes("%")) {
key = decodeURIComponent(key.replaceAll("+", " "));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you're on the right track using replaceAll fn, however there is no need to detect if the key or value contains a "+". Since replaceAll replaces all the instances of "+" we don't need to worry about how many times it appears in the string.

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.

what I am doing right on that if comparison is that I am checking the last two characters, fore example if the key value has an equation like in one of my tests.(a+b+c=x+y+z) so it will check if the last characters include plus sign and then replace it if it is not equation**( first+name, last+name)**. I am not counting rather I am checking. (There is no other way to change +sign even if I decode it).
before I edited the code I used last three to check for equations with an ending of two characters lets say , 2x + 4x. Can you please explain more about what you want me to do here. I need guidance. Thank you .

@hey-hammad hey-hammad 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 16, 2026
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 with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants