Glasgow| 2026-ITP-Jan | Tuan Nguyen| Sprint 2 | Objects#1204
Glasgow| 2026-ITP-Jan | Tuan Nguyen| Sprint 2 | Objects#1204Jacknguyen4438 wants to merge 12 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Some of the code is not consistently formatted.
Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode, as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?
|
@cjyuan Hello and thank you for the feed back I have make some change base on your feed back the brand is ready for your review again. If you read this and see the tag not a course work, sorry for the mis leading tags due to the PR validation system keep reject my request for re-review by remove the need review tags |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
Please revert the change to Sprint-3/alarmclock/index.html on this branch to keep it clean.
| for (const item in object) { | ||
| if (Array.isArray(object[item])) { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
The function is supposed to check only if object is an object that is not an array, and whether the object has a property with the specified name. That is, the function should not need to check the property values.
There was a problem hiding this comment.
THank you for your feed back. I have make some change to make sure the function operate what is suppose to do:
function contains(object, key) {
if (object === null ||typeof object !== "object" || Array.isArray(object)) {
return false;
}
if (Object.keys(object).length === 0) {
return false;
}
for (const item in object) {
if (item === key) {
return true;
}
}
return false;
}
| if (sumArray.length === 0) return {}; | ||
| if (!Array.isArray(sumArray)) { | ||
| throw new Error("Input musk be an array"); | ||
| } |
There was a problem hiding this comment.
If sumArray is null or undefined, line 2 will cause an error to be thrown.
There was a problem hiding this comment.
Thank you for the feed back here is my solution:
function tally(sumArray) {
if (!Array.isArray(sumArray)) {
throw new Error("Input musk be an array");
}
if (sumArray.length === 0) return {};
let totalSum = {};
for (const item of sumArray) {
if (!Object.hasOwn(totalSum, item)) {
totalSum[item] = 1;
} else {
totalSum[item] += 1;
}
}
return totalSum;
}
|
Hello @cjyuan I have make change and ready to be review again |
|
Looks good. |
Learners, PR Template
Self checklist
Changelist
For this PR I have finish all the required section need for PR submission.
Questions
No question.