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

Copy link
Author

Choose a reason for hiding this comment

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

this is my output: [Object: null prototype] { toString: 2 }
is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. This is because the object no longer has an inherited toString() method.

The purpose of using Object.create(null) is so that, when the created object is used as a lookup table, it can accept any string as its property.

An alternative approach is to use a Map object as a lookup table.

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.

Copy link
Author

Choose a reason for hiding this comment

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

I have rewritten my answer for (d) , I am struggling to understand if you mean my answers to (a) and (b) are incorrect, or if it was just the explanation that was incorrect?

@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
@zilinskyte zilinskyte 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 Dec 1, 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. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants