Skip to content

Conversation

@HannaOdud
Copy link

@HannaOdud HannaOdud commented Nov 5, 2025

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

Sprint 1 exercises completed.

Questions

No questions

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@HannaOdud HannaOdud 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 5, 2025
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

5 similar comments
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@HannaOdud HannaOdud changed the title Glasgow | 25-ITP-SEP | Hanna Mykytiuk | Sprint 1| Sprint-1 Glasgow | 25-ITP-SEP | Hanna Mykytiuk |Module-Data-Groups| Sprint-1 Nov 9, 2025
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Groups) doesn't match expected format (example: 'Sprint 2', without quotes)

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

The PR title and the PR description are not quite in the expected format.
Can you update them according to this PR Guide?

if (numbersOnly.length == 0){
return null;
}
const sorted =[...numbersOnly].sort((a,b) => a-b ); //we created a new arrey where we saved sorted element (as string) and turned them to numbers.
Copy link
Contributor

Choose a reason for hiding this comment

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

numbersOnly is no longer the original array and it is not needed later.

So we could improve the performance by not making another copy of the array and
write the code on line 16 as

const sorted = numbersOnly.sort((a, b) => a - b);  // sorted and numbersOnly are the same array

Note: sorted is a more meaningful name so it is good to keep it.

Comment on lines 27 to +32
// Then it should return a copy of the original array

test("given an array with no duplicates, it should return a copy of the original array", () => {
const currentOutput = dedupe([5, 1, 2, 3, 8]);
const targetOutput = [5, 1, 2, 3, 8];
expect(currentOutput).toEqual(targetOutput);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This test should fail if the function returns the original array (instead of a copy of the original array).

The current test checks only if both the original array and the returned array contain identical elements.
In order to validate the returned array is a different array, we need an additional check.

Can you find out what this additional check is?

Comment on lines +65 to +69
test("given an array with non-number values, it should return the max and ignore non-numeric values", () => {
const currentOutput = findMax(["a", "!", 3, 5, "0"]);
const targetOutput = 5;
expect(currentOutput).toEqual(targetOutput);
});
Copy link
Contributor

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 returned the value you expect?

findMax(["1000", 1]);
findMax([1000, "1"]);

Comment on lines +74 to +78
test("given an array with only non-number values, it should return the least surprising value given how it behaves for all other inputs", () => {
const currentOutput = findMax(["2", "3", "$", "%"]);
const targetOutput = "3";
expect(currentOutput).toEqual(targetOutput);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is "3" considered the least surprising value? What's your rationale?

Comment on lines +44 to +48
test("given an array with decimal/float numbers, it should return the correct total sum", () => {
const currentOutput = sum ([2.5, 3.1, 4.9]);
const targetOutput = 10.5;
expect(currentOutput).toEqual(targetOutput);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Decimal numbers in most programming languages (including JS) are internally represented in "floating point number" format. Floating point arithmetic is not exact. For example, the result of 46.5678 - 46 === 0.5678 is false because 46.5678 - 46 only yield a value that is very close to 0.5678. Even changing the order in which the program add/subtract numbers can yield different values.

So the following could happen

  expect( 1.2 + 0.6 + 0.005 ).toEqual( 1.805 );                // This fail
  expect( 1.2 + 0.6 + 0.005 ).toEqual( 1.8049999999999997 );   // This pass
  expect( 0.005 + 0.6 + 1.2 ).toEqual( 1.8049999999999997 );   // This fail

  console.log(1.2 + 0.6 + 0.005 == 1.805);  // false
  console.log(1.2 + 0.6 + 0.005 == 0.005 + 0.6 + 1.2); // false

Can you find a more appropriate way to test a value (that involves decimal number calculations) for equality?

Suggestion: Look up

  • Checking equality in floating point arithmetic in JavaScript
  • Checking equality in floating point arithmetic with Jest

Comment on lines +2 to +18
if (elements.length == 0){ // check if array is empty
return 0;
}
if (elements.length === 1){ //check if array has one element
return elements[0];
}
let sum = 0;
let isNumbersPresent = elements.some(item => typeof item === 'number' && !isNaN(item));
for (let i =0; i<elements.length; i++){ //sum of elements
if (typeof elements[i] === 'number'){ //check if element is number
sum += elements[i];
}
if (isNumbersPresent == false && !isNaN(elements[i])){ //1) check if array doesnt have numbers; 2)check if element can be conversted to number
sum += parseFloat(elements[i]); // add converted to num element
}
}
return sum
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the following function calls return the value you expected?

sum([NaN, 1]);
sum(["A"]);
sum(["10", 1]);
sum(["10", "1"]);

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 20, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Groups) doesn't match expected format (example: 'Sprint 2', without quotes)

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

1 similar comment
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Groups) doesn't match expected format (example: 'Sprint 2', without quotes)

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@HannaOdud HannaOdud changed the title Glasgow | 25-ITP-SEP | Hanna Mykytiuk |Module-Data-Groups| Sprint-1 Glasgow | 25-ITP-SEP | Hanna Mykytiuk | Sprint 1 | Coursework Dec 8, 2025
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

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

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants