Skip to content

London | 26-ITP-January | Mouawia Elkhalifa | Sprint 2 | Data Groups#1077

Open
MouawiaElkhalifa wants to merge 4 commits intoCodeYourFuture:mainfrom
MouawiaElkhalifa:sprint-2
Open

London | 26-ITP-January | Mouawia Elkhalifa | Sprint 2 | Data Groups#1077
MouawiaElkhalifa wants to merge 4 commits intoCodeYourFuture:mainfrom
MouawiaElkhalifa:sprint-2

Conversation

@MouawiaElkhalifa
Copy link
Copy Markdown

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

Implemented all Sprint 2 exercises including:

  • Debug tasks (address, author, recipe)
  • Implement tasks (contains, lookup, querystring, tally)
  • Interpret task (invert)

All functions were tested and verified to meet the expected behavior. Edge cases such as invalid input and duplicate values were handled where required.

@MouawiaElkhalifa MouawiaElkhalifa added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 23, 2026
Comment on lines +44 to +46
test("return false when paramters invaliud ", () =>{
expect(contains([], "a")).toEqual(false)
});
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.

This test does not yet confirm that the function correctly returns false when the first argument is an array.
This is because contains([], "a") could also return false simply because "a" is not a key of the array.

Arrays are objects, with their indices acting as keys. A proper test should use a non-empty array along with a valid
key to ensure the function returns false specifically because the input is an array, not because the key is missing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Strengthened the array test to return false even if an index exists (e.g., contains(["a"], 0)).

@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
@MouawiaElkhalifa MouawiaElkhalifa added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 26, 2026

// d) Explain why the current return value is different from the target output

// e) Fix the implementation of invert (and write tests to prove it's fixed!)
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.

You deleted your answers to these questions.

Anyway, do you recognise what this statement (in the original code) does?

invertedObj.key = value;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Restored missing answers (a-e) and corrected the logic. Replaced literal .key with dynamic [value] notation to prevent overwriting and ensure keys are swapped correctly.

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

Changes look good. Well done.

Comment on lines +1 to +5
// 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the "current return value" refers to the return value of the original code.
The value you showed is the "target return value".
I am sure you know the answers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

thanks,Fixed (a) and (b) — they now show the correct current output.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. 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 Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants