Skip to content

London | 26-ITP-Sept | Hugh Mills | Sprint 1 | Sprint 1 Exercises - #1487

Open
HM-127BTY wants to merge 35 commits into
CodeYourFuture:mainfrom
HM-127BTY:Sprint-1
Open

HM-127BTY wants to merge 35 commits into
CodeYourFuture:mainfrom
HM-127BTY:Sprint-1

Conversation

@HM-127BTY

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

Task code

CYF-1071

Changelist

Completed code and tests in to meet requirements of the tasks in Sprint-1

… input array [3, 1, 2]" working on this test now.
…hout making changed to it using "Array.from(list)"
…nd added in check for .isArray to ensure its an array
… and another with negative and positive numbers
was not able to make commit before this save.
@HM-127BTY HM-127BTY added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 3, 2026
@hackertainment hackertainment 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 Nov 5, 2026
@hackertainment

Copy link
Copy Markdown

Besides fixing the parts in my feedbacks, would you please also commit the code change to refactor/includes.js as well? Thank you.

@hackertainment hackertainment 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 Nov 5, 2026
Comment thread Sprint-1/implement/max.js Outdated
Comment on lines +2 to +4
if (elements.length === 0) {
return "Infinity";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

elements does not necessary have the .length property/attribute. A better approach can be making sure it is an array first. Please fix it. Thank you.

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.

Ah I think I understand, my order for it a touch wrong there.

Best to have it an array first then checking the length is the correct order.

Comment thread Sprint-1/implement/max.test.js Outdated
Comment on lines +19 to +21
it("returns the Infinity for []", () => {
expect(findMax([])).toEqual("Infinity");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It seems not quite accurate to me. Please consider reading line 17 very carefully, and fix the typo in this test case. Thank you.

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.

Ah I see... its ment to be -Infinity not just Infinity. Fixed that error.

@hackertainment hackertainment Nov 7, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In JavaScript, Infinity and -Infinity is a number, so that double-quotes (") are not required. If you have double-quote, then it becomes a string and no longer be a number. The advantage of keeping it as a number is that it can be used for numerical calculation (or comparing with other numbers in this case) - like the example logic below:

let largest = -Infinity;
for (const element of elements) {
    if (element>largest) {
        largest = element;
    }
}
return largest;

As you may aware, this code segment would look cleaner (and actually faster than the built-in sort() function. Since you can spot the typo yourself, I will let you pass this time - but this is actually an important concept in programming. If you would like to learn more about data type, please book a mentored coding session with a volunteer. Thank you.

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.

Thank you, I will look into that.

Comment thread Sprint-1/implement/mean.js Outdated
Comment on lines +2 to +4
if (list.length === 0) {
throw new Error("calculateMean requires a non-empty 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.

list does not necessary have the .length property/attribute. A better approach can be making sure it is an array first. Please fix it. Thank you.

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.

Seen, fixed as same comment as max.js

Comment thread Sprint-1/implement/sum.js Outdated
Comment on lines +2 to +4
if (elements.length === 0) {
return 0;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

elements does not necessary have the .length property/attribute. A better approach can be making sure it is an array first. Please fix it. Thank you.

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.

Seen, fixed as same comment as max.js

Comment thread Sprint-1/implement/sum.js
throw new Error("sum requires an array of numbers");
}

const copyElements = Array.from(elements);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For your future reference, copy an array is not needed as your algorithm just reads but does not modify any elements in it.

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.

Ah I understand, I think i was just copying each time to make sure.

@HM-127BTY

Copy link
Copy Markdown
Author

Ahhh I see my error, i thought i had worked on it but checking now I missed it. Well get right on it. >.<

@hackertainment

Copy link
Copy Markdown

Well done and please note my new comment #1487 (comment) . Congratulation, you have completed this PR successfully.

@hackertainment hackertainment added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 7, 2026
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. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants