Skip to content

London | 26-ITP-Sep | Mahir Shah | Sprint 2 | Sprint 2 coursework - #1505

Open
MahirShah300 wants to merge 19 commits into
CodeYourFuture:mainfrom
MahirShah300:Sprint-2
Open

MahirShah300 wants to merge 19 commits into
CodeYourFuture:mainfrom
MahirShah300:Sprint-2

Conversation

@MahirShah300

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

Fixed all bugs, implemented functions and answered questions

@MahirShah300 MahirShah300 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 8, 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 8, 2026
@github-actions

This comment has been minimized.

@MahirShah300 MahirShah300 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 8, 2026
Comment on lines +49 to +53
test("given something that isn't an object, throw error", () => {
expect(() => contains([1,2,5])).toThrow(
Error("contains requires an object")
);
});

@cjyuan cjyuan Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not use a formatter to keep the code consistently formatted? (The spacing around the array elements is not consistent).

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.

Used prettier to format everything

Comment thread Sprint-2/implement/contains.js Outdated
Comment on lines +5 to +6
(Object.getPrototypeOf(objToCheck) !== Object.prototype &&
Object.getPrototypeOf(objToCheck) !== null)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: This check would also reject objects created as new Map(), Object.create( {} ), and many other types of object. If you just want to check whether objToCheck is an array, there is a more direct approach.

@MahirShah300 MahirShah300 Nov 11, 2026 •

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.

Changed the check to Array.isArray(objToCheck) to check if it is an Array

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

function contains(objToCheck, keyToSearch) {
checkIfObj(objToCheck);
return Object.keys(objToCheck).includes(keyToSearch);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

const obj = { 0: 123 };

// Output false true 123
console.log(contains(obj, 0), contains(obj, '0'), obj[0]);

When a non-string value is used as a key, it is implicitly converted to its string equivalent. However, the code on line 14 treats any non-string keyToSearch as different from its string equivalent.

A better approach would be to use one of Object's built-in methods. Could you find out what this method is?

@MahirShah300 MahirShah300 Nov 11, 2026 •

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.

Used Object.hasOwn(objToCheck, keyToSearch) to check because it does conversions automatically

Comment thread Sprint-2/implement/lookup.js Outdated
Comment on lines +4 to +6
for (const pair of countryCurrencyPairs) {
objCountryCurrencyPairs[pair[0]] = pair[1];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not use array destructuring syntax to make the code more readable?

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.

Changed to for (const [country, currency] of countryCurrencyPairs) { objCountryCurrencyPairs[country] = currency; }

Comment thread Sprint-2/implement/querystring.js Outdated
Comment on lines +13 to +23
if (!pair.includes("=")) {
const key = decodeURIComponent(pair).replace("+", " ");
queryParams[key] = "";
} else {
const key = decodeURIComponent(pair.slice(0, pair.indexOf("="))).replace(
"+",
" "
);
const value = decodeURIComponent(
pair.slice(pair.indexOf("=") + 1)
).replace("+", " ");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you check if parseQueryString('a=x%2By)` is returning the value you expect?

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.

It doesn't, because I was decoding and then replacing, which removed the + character. I now replace + characters first, then decode

@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 10, 2026
@MahirShah300 MahirShah300 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 11, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look good. Well done.

@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 11, 2026
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.

2 participants