London | 26-May-ITP | Yonatan Teklemariam | Sprint 2 | exercises#1237
London | 26-May-ITP | Yonatan Teklemariam | Sprint 2 | exercises#1237Yonatanteklemariam wants to merge 8 commits into
Conversation
…irm if it is working. all checked passed.
|
Hi @LonMcGregor, how are you? I hope you're well. Could you please go through my exercises and give me your feedback? Thanks |
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start, I have a few comments
| // When passed to tally | ||
| // Then it should return an empty object | ||
| test("tally on an empty array returns an empty object", () => { | ||
| expect([]).toEqual({}); |
There was a problem hiding this comment.
I get a failure when I run this test, can you find out why?
| }); | ||
| }); | ||
|
|
||
| test("prints country and currency vertically", () => { |
There was a problem hiding this comment.
Typically the point of using tests is to test the output, if the output is correct, then we can trust that anything printed should be correct. This means we don't want a function under test to print anything. With that in mind, what is the purpose of this test?
| if (typeof item !== "string" || !/^[A-Za-z0-9]+$/.test(item)) { | ||
| throw new Error("Please Enter Valid Input!"); | ||
| } | ||
| counts[item] = (counts[item] ?? 0) + 1; |
There was a problem hiding this comment.
Can you explain how ?? works here?
|
|
||
| // a) What is the current return value when invert is called with { a : 1 } | ||
| // take only the values | ||
| const values = entries.map(([_, v]) => v); |
There was a problem hiding this comment.
Instead of getting the entries, then mapping for the values, is there a faster route to getting the values?
Learners, PR Template
Self checklist
Changelist
debugged all the three functions and fixed them.
implemented the contains() and wrote the tests for it, re-run all of them. all tests checked/passed.