Skip to content

Conversation

@zilinskyte
Copy link

@zilinskyte zilinskyte commented Nov 19, 2025

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

Changelist

Bugs predicted, tested and fixed.
Implement functions based off a set of requirements.
Interpret a program.

Questions

.

@zilinskyte zilinskyte added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. labels Nov 24, 2025
Comment on lines +8 to +14
for (const pair of pairs) {
// Iterate over each pair in the input array
if (Array.isArray(pair) && pair.length >= 2) {
const [countryCode, currencyCode] = pair; // Destructuring first two elements of pair array and assigning them to country and currency
lookup[countryCode] = currencyCode; // Add country-currency pair to the lookup object - later entries overwrite earlier ones if duplicate country codes exist.
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation is a bit off.

Comment on lines 8 to 19
for (const pair of keyValuePairs) {
const [key, value] = pair.split("=");
queryParams[key] = value;
// Iterate over each key-value pair
if (!pair.includes("=")) {
// Handle missing equals sign
queryParams[pair] = undefined; // Assign undefined for keys without equals sign
continue; // Move to the next pair
}
const [key, ...rest] = pair.split("="); // array destructured into key and rest of array.
// Split by '=' to separate key and value.
const value = rest.join("="); // Join back any '=' in the value using rest operator
queryParams[key] = value; // Assign key-value pair to the result object
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please note that in real querystring, both key and value are percent-encoded or URL encoded in the URL. For example, the string "5%" will be encoded as "5%25". So to get the actual value of "5%25" (whether it is a key or value in the querystring), we would need to call a function to decode it.

May I suggest looking up any of these terms, and "How to decode URL encoded string in JS"?

if (!Array.isArray(items)) {
throw new Error("Input must be an array");
}
const counts = {}; // empty object to store tally of key-value pairs
Copy link
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.

Comment on lines +26 to +31

// a) What is the current return value when invert is called with { a : 1 }
// { '1': 'a' }

// b) What is the current return value when invert is called with { a: 1, b: 2 }
// { '1': 'a', '2': 'b' }
Copy link
Contributor

Choose a reason for hiding this comment

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

The "current return value" in questions (a), (b), and (d) refers to the value returned by the original (unmodified) function.

The objects you described on line 28 and 31 are not the objects returned by the original function.
The explanation given on line 41 (answer to question (d)) is also not quite correct.

@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 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Data-Groups The name of the module. 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