Skip to content

Commit 8bd7f4e

Browse files
committed
Resolve sprint 1 merge conflicts and apply mentor feedback
1 parent 2993b07 commit 8bd7f4e

6 files changed

Lines changed: 1 addition & 53 deletions

File tree

Sprint-1/fix/median.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,24 @@ function calculateMedian(list) {
1111
return null;
1212
}
1313

14-
<<<<<<< HEAD
15-
// Keep only real numeric values
16-
const numbersOnly = list.filter(
17-
(item) => typeof item === "number" && !Number.isNaN(item)
18-
);
19-
20-
// Return null if the array contains no numbers
21-
=======
2214
// filter() returns a new array, so this does not modify the original input
2315
const numbersOnly = list.filter((item) => Number.isFinite(item));
2416

2517
// Return null if there are no numeric values
26-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
2718
if (numbersOnly.length === 0) {
2819
return null;
2920
}
3021

31-
<<<<<<< HEAD
32-
// Create a sorted copy so the original input is not changed
33-
const sortedNumbers = [...numbersOnly].sort((a, b) => a - b);
34-
35-
const middleIndex = Math.floor(sortedNumbers.length / 2);
36-
37-
// For an even-length array, median is the average of the two middle values
38-
=======
3922
// Safe to sort directly because numbersOnly is already a new array
4023
const sortedNumbers = numbersOnly.sort((a, b) => a - b);
4124
const middleIndex = Math.floor(sortedNumbers.length / 2);
4225

4326
// Even number of values: return the average of the two middle values
44-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
4527
if (sortedNumbers.length % 2 === 0) {
4628
return (sortedNumbers[middleIndex - 1] + sortedNumbers[middleIndex]) / 2;
4729
}
4830

49-
<<<<<<< HEAD
50-
// For an odd-length array, median is the middle value
51-
=======
5231
// Odd number of values: return the middle value
53-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
5432
return sortedNumbers[middleIndex];
5533
}
5634

Sprint-1/implement/dedupe.test.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ const dedupe = require("./dedupe.js");
22
/*
33
Dedupe Array
44
5-
<<<<<<< HEAD
65
📖 Dedupe means deduplicate
7-
=======
8-
Dedupe means deduplicate
9-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
106
117
In this kata, you will need to deduplicate the elements of an array
128
@@ -27,17 +23,12 @@ test("given an empty array, it returns an empty array", () => {
2723
// Given an array with no duplicates
2824
// When passed to the dedupe function
2925
// Then it should return a copy of the original array
30-
<<<<<<< HEAD
31-
test("given an array with no duplicates, it returns the same values", () => {
32-
expect(dedupe([1, 2, 3])).toEqual([1, 2, 3]);
33-
=======
3426
test("given an array with no duplicates, it returns a copy of the original array", () => {
3527
const input = [1, 2, 3];
3628
const result = dedupe(input);
3729

3830
expect(result).toEqual(input);
3931
expect(result).not.toBe(input);
40-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
4132
});
4233

4334
// Given an array with strings or numbers

Sprint-1/implement/max.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@ function findMax(elements) {
55
let maxValue = -Infinity;
66

77
for (const element of elements) {
8-
<<<<<<< HEAD
9-
// Only compare values that are real numbers
10-
if (typeof element === "number" && !Number.isNaN(element)) {
11-
if (element > maxValue) {
12-
maxValue = element;
13-
}
14-
=======
158
if (Number.isFinite(element) && element > maxValue) {
169
maxValue = element;
17-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
1810
}
1911
}
2012

2113
return maxValue;
2214
}
2315

24-
module.exports = findMax;
16+
module.exports = findMax;

Sprint-1/implement/max.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ test("given an array with decimal numbers, returns the largest decimal", () => {
5151
// When passed to the max function
5252
// Then it should return the max and ignore non-numeric values
5353
test("given an array with non-number values, ignores them and returns the max", () => {
54-
<<<<<<< HEAD
55-
expect(findMax(["hey", 10, "hi", 60, 10])).toBe(60);
56-
=======
5754
expect(findMax(["hey", 10, "300", "hi", 60, 10])).toBe(60);
58-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
5955
});
6056

6157
// Given an array with only non-number values

Sprint-1/implement/sum.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ function sum(elements) {
55
let total = 0;
66

77
for (const element of elements) {
8-
<<<<<<< HEAD
9-
// Only add values that are real numbers
10-
if (typeof element === "number" && !Number.isNaN(element)) {
11-
=======
128
if (Number.isFinite(element)) {
13-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
149
total += element;
1510
}
1611
}

Sprint-1/implement/sum.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ test("given an array with negative numbers, returns the correct sum", () => {
3535
// When passed to the sum function
3636
// Then it should return the correct total sum
3737
test("given an array with decimal numbers, returns the correct sum", () => {
38-
<<<<<<< HEAD
39-
expect(sum([1.5, 2.5, 3])).toBe(7);
40-
=======
4138
expect(sum([1.2, 0.6, 0.005])).toBeCloseTo(1.805, 10);
42-
>>>>>>> a22ed15 (Address mentor feedback for sprint 1 data groups)
4339
});
4440

4541
// Given an array containing non-number values

0 commit comments

Comments
 (0)