Repository navigation
London | 26-ITP-Sep | Bartosz Kawiak | Sprint 2 | Sprint2-exercises - #1508
Open
bartoszkawiak wants to merge 3 commits into
Open
bartoszkawiak wants to merge 3 commits into
bartoszkawiak wants to merge 3 commits into
Conversation
cjyuan
reviewed
Nov 10, 2026
Comment on lines
+41
to
+48
|
|
||
| test("when given single input should invert key and value eg. 'a:1', return '1:a' ", () => { | ||
| expect(invert({ a: 1 })).toEqual({ 1: "a" }); | ||
| }); | ||
|
|
||
| test("when given multiple inputs should invert key and values correctly ", () => { | ||
| expect(invert({ a: 1, b: 3 })).toEqual({ 1: "a", 3: "b" }); | ||
| }); |
Contributor
There was a problem hiding this comment.
In this exercise, you only need to interpret the code. Your answers to the questions are good.
The goal is to be able to distinguish the difference between these two syntax:
obj[key]obj.key
Tests are optional and you could leave the test code here if you want.
Author
There was a problem hiding this comment.
Thanks for explaining CJ. I'll keep the tests in a single file for better access.
Contributor
|
Changes look good. Thanks for responding to all comments clearly. Well done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Task code
CYF-1083
Changelist
Completed the latest Sprint 2 exercises, working with JavaScript objects, key-value pairs and loops. Added tests, fixed bugs and improved my understanding of how to work with objects.
Questions
I did not know if I should make a new test file for invert.js file or just write down tests below comments.