-
-
Notifications
You must be signed in to change notification settings - Fork 158
Sheffield| May 2025| Mayowa Fadare|Module data sprint 2 #683
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
Conversation
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.
-
Code is pretty solid. Good job.
-
stretch/count-words.js
andtill.js
were not fully implemented. So I didn't leave any comment to them.
Sprint-2/implement/tally.js
Outdated
function tally(items) { | ||
if (!Array.isArray(items)) { | ||
throw new Error("Input must be an array"); | ||
} | ||
const counts = {}; | ||
for (const item of items) { | ||
if (typeof item !== "string" && typeof item !== "number") { | ||
throw new Error("Items must be strings or numbers"); | ||
} | ||
counts[item] = (counts[item] || 0) + 1; | ||
} | ||
return counts; | ||
} |
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?
-
Can you check if your function returns what you expect from the following function call?
tally(["toString", "toString", "toString"]);
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.
Thanks for the review, code now well indented and function call updated. ✅
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 code in tally.js
is not working properly after change.
Sprint-2/implement/tally.js
Outdated
@@ -1,16 +1,16 @@ | |||
|
|||
function tally(items) { | |||
function tally(["toString", "toString", "toString"]); { |
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 code even run? My previous comment was
Can you check if your function returns what you expect from the following function call?
tally(["toString", "toString", "toString"]);
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.
No it doesn't, but I have effected it with the correct function
Sprint-2/implement/tally.js
Outdated
const counts = {}; | ||
for (const item of items) { | ||
if (typeof item !== "string" && typeof item !== "number") { | ||
throw new Error("Items must be strings or numbers"); | ||
} | ||
counts[item] = (counts[item] || 0) + 1; | ||
} |
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.
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.