-
-
Notifications
You must be signed in to change notification settings - Fork 178
Birmingham | 25-ITP-Sep | Joy Opachavalit | Sprint 1 | Sprint-1 #800
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
cjyuan
left a comment
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 missed updating Sprint-1/implement/sum.js and Sprint-1/implement/sum.test.js.
| test("given an array with no duplicates, returns a copy of the original array", () => { | ||
| expect(dedupe([1, 2, 3])).toEqual([1, 2, 3]); | ||
| expect(dedupe(["a", "b", "c"])).toEqual(["a", "b", "c"]); | ||
| }); |
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 test code cannot check if the returned array is a copy of the original array because toEqual() compares objects (including arrays) by value. To illustrate,
const A = [2, 3, 1];
const B = [...A]; // B is a copy of A
// This set of code cannot distinguish if the compared objects are the same objects.
expect(A).toEqual(A); // true
expect(A).toEqual(B); // true
In order to check if the returned array is a copy of the original array, we would need additional checks.
Can you find out what code you need to add in order to ensure the returned value is not the original array?
| for (let i = 1; i < numbers.length; i++) { | ||
| if (numbers[i] > max) { | ||
| max = numbers[i]; | ||
| } | ||
| } | ||
| return max; | ||
| } |
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.
Can you improve the indentation of this code?
| if (numbers.length === 0) { | ||
| if (elements.length === 0) { | ||
| return -Infinity; | ||
| } else { | ||
| return null; | ||
| } | ||
| } |
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.
Could also consider an array with no numbers the same as an array with no elements. The latter also does not have any number.
Learners, PR Template
Self checklist
Changelist
-Completed all excercises in Sprint-1