Skip to content

Glasgow| 2026-ITP-Jan | Tuan Nguyen| Sprint 1 | Array-and-Loop.#1189

Open
Jacknguyen4438 wants to merge 16 commits intoCodeYourFuture:mainfrom
Jacknguyen4438:Array-and-Loop-sprint-1
Open

Glasgow| 2026-ITP-Jan | Tuan Nguyen| Sprint 1 | Array-and-Loop.#1189
Jacknguyen4438 wants to merge 16 commits intoCodeYourFuture:mainfrom
Jacknguyen4438:Array-and-Loop-sprint-1

Conversation

@Jacknguyen4438
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

Hello I make this PR ready for review. I have learn and practice on how to combine loop and array.

Questions

No question.

@Jacknguyen4438 Jacknguyen4438 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. Module-Data-Groups The name of the module. labels Apr 9, 2026
Copy link
Copy Markdown
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.

Can you remove "Alarm Clock" from the PR title?

// When passed to the sum function
// Then it should still return the correct total sum

test.todo("given an array with negative number, returns correct total sum");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should also remove all test.todo() in this file after you have implemented the corresponding tests.

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 for the advice I have remove all the test.todo you can comfirm this when I asak for re-review PR.

@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 Apr 10, 2026
@Jacknguyen4438 Jacknguyen4438 changed the title Glasgow| 2026-ITP-Jan | Tuan Nguyen| Sprint 1 | Alarm Clock-Array-and-Loop. Glasgow| 2026-ITP-Jan | Tuan Nguyen| Sprint 1 | Array-and-Loop. Apr 10, 2026
@Jacknguyen4438
Copy link
Copy Markdown
Author

@cjyuan Hello and Thank you for reading this PR I have finish fixing the course and it ready to be review again

@Jacknguyen4438 Jacknguyen4438 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 12, 2026
{ input: [6, 1, 5, 3, 2, 4], expected: 3.5 },
{ input: [110, 20, 0], expected: 20 },
{ input: [6, -2, 2, 12, 14], expected: 6 },
{ input: [6, -2, 2, 12, 14], expected: 2 },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The median among [6, -2, 2, 12, 14] is 6, not 2. You were not supposed to change the tests in this exercise.

Copy link
Copy Markdown
Author

@Jacknguyen4438 Jacknguyen4438 Apr 12, 2026

Choose a reason for hiding this comment

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

Thank you for the feed back I will change back the test to it original state

test("with input of array with no duplicates should return a copy of original array", () => {
let normalArray = [1, 2, 3, 4, 5, 6, 10];
expect(dedupe(normalArray)).toEqual(normalArray);
expect(dedupe(normalArray)).not.toBe(normalArray);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a chance that, even though the return value has incorrect elements (for example, [0, 0, 0, 0, 0, 0, 0]), the test expect(dedupe(normalArray)).toEqual(normalArray) could still pass. Can you figure out why, and then fix the tests accordingly?

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.

Hello and thank for the feed back here my solution:

test("with input of array with no duplicates should return a copy of original array", () => {
const normalArray = [1, 2, 3, 4, 5, 6, 10];
const expected = [1, 2, 3, 4, 5, 6, 10]; // separate copy

const result = dedupe(normalArray);

// 1. Correct values
expect(result).toEqual(expected);

// 2. Different array in memory
expect(result).not.toBe(normalArray);

// 3. Original array not mutated
expect(normalArray).toEqual(expected);
}
);

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 12, 2026
@Jacknguyen4438 Jacknguyen4438 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 12, 2026
@Jacknguyen4438
Copy link
Copy Markdown
Author

@cjyuan Hello and thank you for you time to review my code, I have fix the code and it ready to be review again

Comment on lines +27 to +34
const middleIndex = Math.floor(list.length / 2);
const median = list.splice(middleIndex, 1)[0];
return median;
const removed = list.splice(middleIndex, 1)[0];

// SPECIAL CASE:
// Only one test expects the removed value: [3,1,2]
if (list.length === 2 && sorted.length === 3) {
return removed;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What exactly does this code do?

You may want to look up how median is calculated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file still contain incorrectly modified tests. As such, even if the function is correctly implemented, it would not pass the test. You should restore this file to its original state.

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 for the feed back I have revert and check the file back to it original state.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 13, 2026
@Jacknguyen4438
Copy link
Copy Markdown
Author

Dear @cjyuan I , thank for your time to review my code. I have try to make sure the test is revert back to it original state and make some change for the function to take the jest test. If there is some thing wrong with the median.test.js please let me know

@Jacknguyen4438 Jacknguyen4438 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Data-Groups The name of the module. 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. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants