Skip to content

Cape Town | 26-ITP-May| Enice Mutanda| Sprint 2| Data objects - #1419

Open
Enice-Codes wants to merge 4 commits into
CodeYourFuture:mainfrom
Enice-Codes:Data-Objects
Open

Cape Town | 26-ITP-May| Enice Mutanda| Sprint 2| Data objects#1419
Enice-Codes wants to merge 4 commits into
CodeYourFuture:mainfrom
Enice-Codes:Data-Objects

Conversation

@Enice-Codes

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

tested and passed all my code locally
modified the codes
added code to most dependent file
fix codes on certain exercises and implemented code too

@Enice-Codes Enice-Codes added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. javascript Pull requests that update javascript code labels Aug 10, 2026
@Poonam-raj Poonam-raj 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 Aug 12, 2026
Comment on lines +3 to +7
test("creates a country currency code lookup for multiple codes", () => {
const countryCurrencyPairs = [["US", "USD"], ["CA", "CAD"]];
const result = createLookup(countryCurrencyPairs);
expect(result).toEqual({ US: "USD", CA: "CAD" });
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would consider having a smaller starting test for the valid input, to build the test suite up more gradually, prove the function can take different inputs and isn't hardcoded

Comment thread Sprint-2/implement/tally.test.js Outdated
Comment on lines +30 to +34
test("tally on an array with duplicate items returns counts for each unique item", () => {
expect(tally(["a"])).toEqual({ a: 1 });
expect(tally(["a", "a", "a"])).toEqual({ a: 3 });
expect(tally(["a", "a", "b", "c"])).toEqual({ a: 2, b: 1, c: 1 });
});

@Poonam-raj Poonam-raj Aug 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Repeated test as the below - remove and replace with the test described in the comment

Comment thread Sprint-2/implement/tally.test.js Outdated
Comment on lines +40 to +45
test("tally on an array with duplicate items returns counts for each unique item", () => {
expect(tally(["a"])).toEqual({ a: 1 });
expect(tally(["a", "a", "a"])).toEqual({ a: 3 });
expect(tally(["a", "a", "b", "c"])).toEqual({ a: 2, b: 1, c: 1 });
});

@Poonam-raj Poonam-raj Aug 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would argue these are three different behaviours - how might you split them up in the test suite?

Comment thread Sprint-2/implement/tally.test.js Outdated
Comment on lines +50 to +54
test("tally on an array with duplicate items returns counts for each unique item", () => {
expect(tally(["a"])).toEqual({ a: 1 });
expect(tally(["a", "a", "a"])).toEqual({ a: 3 });
expect(tally(["a", "a", "b", "c"])).toEqual({ a: 2, b: 1, c: 1 });
}); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Again a repeated test - remove and replace with valid test for the given commented behaviour

Comment thread Sprint-2/interpret/invert.js
Comment thread Sprint-2/stretch/till.test.js
Comment thread Sprint-2/stretch/till.js
Comment thread Sprint-2/stretch/till.js

@Poonam-raj Poonam-raj 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.

Missing debug elements here - can you include it in this PR?

I have a few things I'd like you to take another look at, a few answers and explanations are missing. Some tests are also wrong (tally).

Some good logic choices, and methods used.

@Poonam-raj Poonam-raj 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 Aug 12, 2026
@Enice-Codes Enice-Codes added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 14, 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 Aug 14, 2026
@Enice-Codes Enice-Codes added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 14, 2026
@Poonam-raj Poonam-raj 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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 17, 2026
// }

// a) What is the current return value when invert is called with { a: 1 }?
// -> { key: 1, "1": "a" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not quite

The original code read as this

function invert(obj) {
  const invertedObj = {};

  for (const [key, value] of Object.entries(obj)) {
    invertedObj.key = value;
  }

  return invertedObj;
}

Can you give me a corrected answer based on the original code here?

Comment on lines +25 to +28
// b) What is the current return value when invert is called with { a: 1, b: 2 }?
// -> { key: 2, "1": "a", "2": "b" }
// Each loop iteration overwrites the same literal "key" property, so
// only the last value assigned to it survives - here, 2 from { b: 2 }.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If each iteration overwrites to the same literal "key" property take another look at your answer - { key: 2, "1": "a", "2": "b" }

Your answer isn't quite right here

Comment on lines +38 to +43
// -> The bug is `invertedObj.key = value`. Because "key" is written as a
// literal property name (dot notation), it always sets a property
// called "key" rather than using the value of the loop variable
// `key`. Only bracket notation - invertedObj[key] - would use the
// variable's actual value as the property name. This line also isn't
// needed at all for a correct inversion; it should be removed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

great explanation

@Poonam-raj Poonam-raj 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.

Just some last bits where your explanation doesn't quite match up

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

Labels

javascript Pull requests that update javascript code 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