Skip to content

Birmingham | ITP-Jan | Roman Sanaye | Sprint 2 | Exercises#1019

Open
RomanSanaye wants to merge 10 commits intoCodeYourFuture:mainfrom
RomanSanaye:Sprint-2-Exercises
Open

Birmingham | ITP-Jan | Roman Sanaye | Sprint 2 | Exercises#1019
RomanSanaye wants to merge 10 commits intoCodeYourFuture:mainfrom
RomanSanaye:Sprint-2-Exercises

Conversation

@RomanSanaye
Copy link

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

  • Completed all exercises in this sprint, including the following folders:
    • Debugging: fixed errors and improved code logic.
    • Implement: implemented required functions and features as instructed.
    • Interpret: interpreted given code snippets and exercises.
    • Stretch: completed advanced challenges, including the totalTill function.
  • Added Jest tests for key functions where required, including the totalTill function.
  • Ensured all functions are beginner-friendly, tested, and formatted according to the style guide.

Questions

No questions at this time.

@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
@cjyuan cjyuan 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 Mar 22, 2026
Comment on lines +3 to +7
let output = {};
for (let pair of input) {
let key = pair[0];
let value = pair[1];
output[key] = value;
Copy link
Contributor

Choose a reason for hiding this comment

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

output and pair are not going to be reassigned a value, so a better practice is to declare them using const.

We can still modify the array or object assigned to a constant in JS, we just cannot reassign another value to the constant.

Copy link
Author

Choose a reason for hiding this comment

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

let was replaced with const, and it is a safer option.

@cjyuan cjyuan 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 Mar 22, 2026
@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 23, 2026
Copy link
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.

Other changes look good.

let object = [1, 2, 3];
let key = "name";
expect(contains(object, key)).toEqual(false);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

In practice, we prepare tests not just to check our own implementation, but also to guard against future modification.

Currently, this incorrectly implemented function could also pass this test:

function contains(object, key) {
  if (object === null || typeof object !== "object") {
    return false;
  }
  return Object.prototype.hasOwnProperty.call(object, key);
}

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 23, 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