Skip to content

Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 2 | Module-Data-Groups#1099

Open
mshayriyesaricicek wants to merge 5 commits intoCodeYourFuture:mainfrom
mshayriyesaricicek:Sprint-2
Open

Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 2 | Module-Data-Groups#1099
mshayriyesaricicek wants to merge 5 commits intoCodeYourFuture:mainfrom
mshayriyesaricicek:Sprint-2

Conversation

@mshayriyesaricicek
Copy link
Copy Markdown

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

Exercises for Sprint 2

@github-actions

This comment has been minimized.

@mshayriyesaricicek mshayriyesaricicek changed the title Sheffield || ITP-Jan-26 || Hayriye Saricicek || Sprint 2 || Module-Data-Groups Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 2 | Module-Data-Groups Mar 25, 2026
@mshayriyesaricicek mshayriyesaricicek added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 25, 2026
Copy link
Copy Markdown
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.

You missed updating Sprint-2/interpret/invert.js.

@@ -1,3 +1,8 @@
function contains() {}
function contains(obj, key) {
if (typeof obj !== "object" || Array.isArray(obj)) {
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.

Unfortunately typeof null was mistakenly evaluated to "object" in the language, and they cannot change that now.

if (typeof obj !== "object" || Array.isArray(obj)) {
throw new Error("Input must not be an array");
}
return key in obj;
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.

Consider the following two approaches for determining if an object contains a property:

  let obj = {}, propertyName = "toString";
  console.log( propertyName in obj );                // true
  console.log( Object.hasOwn(obj, propertyName) );   // false

Which of these approaches suits your needs better?
For more info, you can look up JS "in" operator vs Object.hasOwn.

const [key, value] = pair.split("=");
const [key, ...rest] = pair.split("=");
const value = rest.join("=");
queryParams[key] = value;
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: (No change required)

  • In real query string, both key and value are percent-encoded or URL encoded in the URL.
    For example, the string "5%" is encoded as "5%25". So to get the actual value of "5%25"
    (whether it is a key or value in the query string), we need to call a function to decode it.

  • You can also explore the URLSearchParams API.

Comment on lines +6 to +14
const result = {};

for (const item of arr) {
if (item in result) {
result[item] = result[item] + 1;
} else {
result[item] = 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.

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 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 Mar 25, 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.

2 participants