Skip to content

Conversation

@asaniDev
Copy link

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

Added tests to my tasks before creating functions to pass the tests, completed all tasks.

@asaniDev asaniDev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 17, 2025
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.

Can you check if any of this general feedback can help you further improve your code?
https://github.com/CodeYourFuture/Module-Data-Groups/blob/sprint-1-feedback/Sprint-1/feedback.md

Doing so can help reviewers speed up the review process. Thanks.

@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
@asaniDev asaniDev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 29, 2025
return (numberArray[middleIndex] + numberArray[middleIndexPlus1]) / 2;
}

return numberArray.splice(Math.floor(numberArray.length / 2), 1)[0];
Copy link
Contributor

@cjyuan cjyuan Dec 2, 2025

Choose a reason for hiding this comment

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

Can you simplify this statement (line 57)?

Comment on lines +46 to +55
let middleIndex = 0;
let middleIndexPlus1 = 0;

if (numberArray.length % 2 === 0) {
//if array has even number of items then a different median formula
middleIndex = Math.floor(numberArray.length / 2);
middleIndexPlus1 = middleIndex - 1;

return (numberArray[middleIndex] + numberArray[middleIndexPlus1]) / 2;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If these two variables are used only inside the if block, it is better to declare them inside the block.

Comment on lines +31 to +37
if (Array.isArray(list)) {
//checking if we have been passed an array before picking numbers from any arrays
numberArray = list.filter(isNumber);
console.log(`new array ${numberArray}`);
} else {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Since the function will return immediately if list is not an array, we could simplify the code as:
  if (!Array.isArray(list)) return null;
  
  // no need else and no need to introduce {...} block
  ...
  

  1. It's best practice to keep the code clean by removing all the debugging code. Can you remove all the unnecessary console.log() statements?

Comment on lines +19 to +25
function isNumber(value) {
if (typeof value === "number") {
return true;
}

return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could simplify

  if (condition)
    return true;
  return false;

into

  return condition;          // Note: Use !!(condition) if condition is not a Boolean-type value

return [];
} else if (myArray.length === myArray.filter(checkForDupe).length) {
//return copy of array if no duplicates
return myArray;
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not return a copy of myArray.

Copy link
Contributor

Choose a reason for hiding this comment

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

This function has several bugs.

You may want to reimplement it following this approach:

  • First create a new array to keep only the values you consider "valid".
  • Then find the max in the new array.
    • When dealing with the elements in this new array, you don't have to check for invalid values.

Comment on lines +4 to +5
for (item of list) {
const element = item;
Copy link
Contributor

Choose a reason for hiding this comment

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

  • item is not delcared.
  • Code on lines 4 and 5 could further be simplified.

Comment on lines +3 to +9
function numberOfFloat(number) {
if (Number.isInteger(number)) {
return 0;
} else {
return number.toString().split(".")[1].length;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This approach to figure out number of decimal places does not work for all floating point numbers.

  • Some floating point numbers can also be represented in scientific format. For examples, 1e-100, 3.12e50.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have to praise you for going through a great length to implement a sum() function that takes into consideration the number of decimal places in the input array.

input: ["the ", "quick ", "brown ", "fox ", "jumped"],
expected: "the quick brown fox jumped",
},
{ input: [-1000, -500, -450, -320, -2300, -170, -260], expected: -5000 },
Copy link
Contributor

Choose a reason for hiding this comment

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

These values are numbers.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 3, 2025
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants