London |ITP-Jan-2016 | Ping Wang | Sprint 2 |Coursework#1023
London |ITP-Jan-2016 | Ping Wang | Sprint 2 |Coursework#1023pathywang wants to merge 11 commits intoCodeYourFuture:mainfrom
Conversation
| if (!Array.isArray(array)) { | ||
| throw new Error("Invalid input: expected an array"); | ||
| } | ||
|
|
||
| const count={} | ||
| for(item of array){ | ||
| if (count[item]){ | ||
| count[item] += 1 | ||
| } | ||
| else{ | ||
| count[item] = 1 | ||
| } | ||
| } | ||
| return count | ||
| } |
There was a problem hiding this comment.
-
Can you improve the indentation?
-
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.
There was a problem hiding this comment.
Thank you for the suggestion. It is the first time i hear the empty object with no inherited properties. i went to AI help who explained to me about the advantage of no inherited properties. i am trying to practice with my code from now on.
cjyuan
left a comment
There was a problem hiding this comment.
Please note that in CYF courses, the recommended way to inform the reviewer of your changes is to do both of the following:
- Reply to their feedback.
- In the responses, clarify how each piece of feedback was addressed to demonstrate that you've carefully reviewed the suggestions.
- You may find the suggestions in this PR Guide useful.
- Your response may trigger a notification (depending on the reviewer's settings), helping ensure they’re aware of the updates you’ve made.
- In the responses, clarify how each piece of feedback was addressed to demonstrate that you've carefully reviewed the suggestions.
- Replace the "Reviewed" label by a "Needs review" label (which you have done -- great!)
- Without this label, the reviewer would not know if your changes is ready to be reviewed.
| if (!Array.isArray(array)) { | ||
| throw new Error("Invalid input: expected an array"); | ||
| } | ||
|
|
||
| const count = Object.create(null); | ||
|
|
||
| for (const item of array) { | ||
| if (count[item]) { | ||
| count[item] += 1; | ||
| } else { | ||
| count[item] = 1; | ||
| } | ||
| } | ||
|
|
||
| return count; | ||
| } |
There was a problem hiding this comment.
Code is not yet properly indented. Can you fix the identation?
If you have enabled "Format on save" but it is not working, it is likely that you haven't assign a formatter for JS file. This could happen if you have zero or multiple extensions that can format .js file.
If you have installed "Prettier" extension. To assign it as the formatter of JS code, you can try:
- Use "Format document" to format the JS file. Sometimes, VSCode will ask you to choose a formatter, and you can manually select "Prettier".
- Edit
settings.jsonand set Prettier as the default formatter for JS.
See: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
There was a problem hiding this comment.
sorry sometimes i forgot about indention syntax because i pay more attention on node running, the rule is about 2 standard space for indentation and allign the parallel function
There was a problem hiding this comment.
i would put comment on after i correct my code according PR guide which give me another chance to review correction. What is more, i know what is the reason for correction later on.
There was a problem hiding this comment.
If you have successfully enabled "Format on save" and assign "Prettier" as your JS code formatter on VSCode, you won't have to worry about indentation and code format anymore.
|
Changes look good. Well done. |
|
Thank you for your suggestion and correction, really appreciate it!
kind regards
ping
…On Sun, 22 Mar 2026 at 16:04, CJ Yuan ***@***.***> wrote:
*cjyuan* left a comment (CodeYourFuture/Module-Data-Groups#1023)
<#1023 (comment)>
Changes look good. Well done.
—
Reply to this email directly, view it on GitHub
<#1023?email_source=notifications&email_token=BR4KUR73L7PLTVQVRZCVFWD4SAFINA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJQGY2TCMJVHA3KM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4106511586>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BR4KUR3BHGSWFW5ACTKVM3L4SAFINAVCNFSM6AAAAACWUF3B5CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCMBWGUYTCNJYGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Self checklist
Changelist
i did coursework with node or npm jest to check my work to make sure that my code works as expected after i completed my prep