-
-
Notifications
You must be signed in to change notification settings - Fork 191
Birmingham | ITP-Sep-25 | Ahmad Ehsas | sprint 2 | Data groups #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rray and passed the tests of given arrays.
…seNumber property.
…by join(\n) method.
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
3 similar comments
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
Can you address these issues? |
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Data Groups) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
You can view all the changed files of this PR branch on https://github.com/CodeYourFuture/Module-Data-Groups/pull/805/files You copied the Sprint-1 folder into the wrong folder; you haven't yet replaced the modified Sprint-1 folder. Can you make this branch clean? |
|
As I had this issue in my previous module, 'Structuring and testing data' then i followed your instructions: In VSCode, switch to this branch (Sprint-2). Copy these files from the ZIP file to this branch (make sure they are copied to the right folder) I did this, and now I am a little bit confused, and I need your clarification in more detail. |
|
You did everything right, except copying the "Sprint-1" folder to the right folder. I think you can easily fix the issue by
If you need interactive assistance, I am available today or tomorrow evening. You can DM me on Slack, "CJ Yuan". |
Sprint-2/debug/author.js
Outdated
| // This means that we need to check if the property belongs to the object using hasownproperty whenever we loop through an object with the `for ... in` loop. | ||
|
|
||
| for (const key in author) { | ||
| if (author.hasOwnProperty(key)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why introduce the if-statement on line 21? Can you justify its need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tested my code without the 'if ... statement', it worked, but the if ... statement is neccessary if there might be properties inherited from the prototype chain.
So the 'if' check doesn't change the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You can output the value of
keywithin the loop to see what values you get - You can also use AI to help you clarify some concept
| test("contains on an array returns false", () => { | ||
| expect(contains([1, 2, 3], 4)).toBe(false); | ||
| }); | ||
|
|
||
| test("contains on an array of length returns true", () => { | ||
| expect(contains([1, 2, 3, 4], "length")).toBe(true); | ||
| }); // the test returns true because 'length' is a property of the array object | ||
|
|
||
| test("contains given on array as input return false", () => { | ||
| expect(contains([1, 2, 3], "a")).toBe(false); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these function calls return what you expect?
contains([1, 2, 3], "0");
contains(null, "a");
contains(undefined, "a");
contains(1234, "a");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My function checks for its own property on an object. For the first input `contains([1, 2, 3], "0"); return true because arrays are objects and "0" is a property key.
Inputs like 'null', 'undefined', and '123' will cause errors because they are not objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case you may want to update the test descriptions on lines 44 and 52.
| const keyValuePairs = queryString.split("&"); | ||
|
|
||
| for (const pair of keyValuePairs) { | ||
| const [key, value] = pair.split("="); | ||
| const [key, value] = pair.split(/=(.+)/); // We use regex to split only at first. | ||
| queryParams[key] = value; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this function call return what you expect?
parseQuerySring("A=");
In real query string, both key and value are percent-encoded or URL encoded.
For example,
tags%5B%5D=hello%20world-> key istags[], value ishello world
Can your function handle URL-encoded query string?
Suggestion: Look up "How to decode a URL-encoded string in JavaScript".
Sprint-2/implement/tally.js
Outdated
| throw new Error("Input must be an array"); | ||
| // check if the input ia an array. if not, throw an error. | ||
| } | ||
| const tally = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the following function call returns the value you expect?
tally(["toString", "toString"]);
Suggestion: Look up an approach to create an empty object with no inherited properties.
Sprint-2/interpret/invert.js
Outdated
| // The current return value is {1: "a"} | ||
|
|
||
| // b) What is the current return value when invert is called with { a: 1, b: 2 } | ||
| // The current return value is {1: "a", 2: "b"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "current return value" refers to the value returned by the original (unmodified) function.
With the original function, the objects you described on line 23 and 26 are not the objects returned by the function.
Can you find out the actual object returned by the original function?
Sprint-2/debug/author.js
Outdated
| for (const key in author) { | ||
| if (author.hasOwnProperty(key)) { | ||
| // if (author.hasOwnProperty(key)) { | ||
| console.log(`${key}: ${author[key]}`); | ||
| } | ||
| } | ||
| //} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| test("contains on an array of length returns true", () => { | ||
| expect(contains([1, 2, 3, 4], "length")).toBe(true); | ||
| // expect(contains([1, 2, 3, 4], "length")).toBe(true); | ||
| expect(contains(null, "a", "length")).toBe(true); | ||
| }); // the test returns true because 'length' is a property of the array object | ||
|
|
||
| test("contains given on array as input return false", () => { | ||
| expect(contains([1, 2, 3], "a")).toBe(false); | ||
| // expect(contains([1, 2, 3], "a")).toBe(false); | ||
| expect(contains(1234, "a")).toBe(false); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you expect the function to accept an array as its first parameter or not? These two test descriptions are contradicting each other.
| // The current return value is {'1': 'a'} | ||
|
|
||
| // b) What is the current return value when invert is called with { a: 1, b: 2 } | ||
| // The current return value is {1: "a", 2: "b"} | ||
| // The current return value is {'1': 'a', '2': 'b'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are still not the objects returned by the original (unmodified) function.

Self checklist
Changelist
I have completed all the required tasks.
Questions