Skip to content

Glasgow | Jan-26 | Elisabeth Matulian | Sprint 2 | Exercises#981

Closed
Elisabeth-Matulian wants to merge 4 commits into
CodeYourFuture:mainfrom
Elisabeth-Matulian:sprint-2
Closed

Glasgow | Jan-26 | Elisabeth Matulian | Sprint 2 | Exercises#981
Elisabeth-Matulian wants to merge 4 commits into
CodeYourFuture:mainfrom
Elisabeth-Matulian:sprint-2

Conversation

@Elisabeth-Matulian
Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Completed exercises for Sprint 2

@Elisabeth-Matulian Elisabeth-Matulian added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 6, 2026
@JaypeeLan JaypeeLan added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 11, 2026
Comment thread Sprint-2/implement/tally.js Outdated
Comment on lines +1 to +11
function tally(array) {
let object = {};
if (Array.isArray(array)) {
for (const i of array) {
if (object.hasOwnProperty(i)) {
object[i] = object[i] + 1;
}
else object[i] = 1;
}
return object;}
else throw new Error("Invalid input");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good implementation overall. Suggest improving variable naming, adding braces for readability, and using Object.prototype.hasOwnProperty.call for safer property checks.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. Yesterday I learnt a new method (||= and ??=) and wanted to put it into practice; It also seems to me, the code looks better this way.

Comment thread Sprint-2/implement/tally.js Outdated
function tally() {}
function tally(array) {
let object = {};
if (Array.isArray(array)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using early return for the check, just the way you have in the function that checks if an object has a property. So if it is not a valid array, just return. No need to continue with the function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@JaypeeLan JaypeeLan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Mar 11, 2026
@Elisabeth-Matulian Elisabeth-Matulian added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 13, 2026
@Elisabeth-Matulian Elisabeth-Matulian added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 26, 2026
@illicitonion
Copy link
Copy Markdown
Member

Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants