Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9e46794
Fixing Median exercice
hamdiheb Jan 9, 2026
4bd9b7c
Median Exercice
hamdiheb Jan 11, 2026
d00ce57
Median Exercice
hamdiheb Jan 11, 2026
9316929
Median fixed to pass 19 check
hamdiheb Jan 11, 2026
130a93d
Median exercice fixed sprint1
hamdiheb Jan 11, 2026
a89b3dc
Dedupe exercice
hamdiheb Jan 11, 2026
049cd6c
Added tests for dedupe function file and done max function
hamdiheb Jan 11, 2026
3f955c1
Tests for the max function
hamdiheb Jan 11, 2026
c09cbfc
Sum exercice with testing
hamdiheb Jan 11, 2026
c5e61ba
Exercice includes from refactor
hamdiheb Jan 11, 2026
aa82cef
Solved the quizz for the frequency
hamdiheb Jan 11, 2026
c6dbddd
Address object exercice
hamdiheb Jan 16, 2026
430931c
katas done
hamdiheb Jan 18, 2026
9ddec47
Author exercice
hamdiheb Jan 18, 2026
7d613d2
Recipe exercice
hamdiheb Jan 18, 2026
3456633
Tally exercice
hamdiheb Jan 18, 2026
239bda1
Added tests to contains script
hamdiheb Jan 18, 2026
3a6ffd4
Added tests for lookup script
hamdiheb Jan 18, 2026
c206ba4
Done testing on tally
hamdiheb Jan 18, 2026
27c354e
query string
hamdiheb Jan 18, 2026
eda1947
Invert exercice
hamdiheb Jan 18, 2026
d6c6541
Address Exercice
hamdiheb Jan 18, 2026
fa9bbc3
Author exercice
hamdiheb Jan 18, 2026
62fe935
recipe exercice
hamdiheb Jan 18, 2026
c138b96
contains exercice
hamdiheb Jan 18, 2026
2afd36e
Testing for contains and lookup exercice
hamdiheb Jan 18, 2026
e77b539
look up testing exercice
hamdiheb Jan 18, 2026
13cf5c4
Querystring script
hamdiheb Jan 18, 2026
30b09e4
Testing for querystring
hamdiheb Jan 18, 2026
35c3965
tally script
hamdiheb Jan 18, 2026
a5d3f2a
tally script testing
hamdiheb Jan 18, 2026
3661c1b
invert script
hamdiheb Jan 18, 2026
a011e49
Alarm Clock
hamdiheb Jan 23, 2026
37176e0
Quotes app
hamdiheb Jan 23, 2026
84689ec
Reading List
hamdiheb Jan 24, 2026
e336cdf
Reading list , added testing for readbook status iif true or false
hamdiheb Jan 24, 2026
d5b5de5
Slider update , forward button
hamdiheb Jan 25, 2026
e9db75f
Slider update , backwards button
hamdiheb Jan 25, 2026
8f372b8
Slider auto function
hamdiheb Jan 25, 2026
f092fd0
Going through logic of todo list
hamdiheb Jan 25, 2026
e0482ae
Going through logic of todo list
hamdiheb Jan 25, 2026
59d1eb1
Alarm Clock App
hamdiheb Jan 25, 2026
c519c3c
Alarm Clock App
hamdiheb Jan 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions Sprint-1/fix/median.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,30 @@
// Hint: Please consider scenarios when 'list' doesn't have numbers (the function is expected to return null)
// or 'list' has mixed values (the function is expected to sort only numbers).


function calculateMedian(list) {
const middleIndex = Math.floor(list.length / 2);
const median = list.splice(middleIndex, 1)[0];
return median;

const check=Array.isArray(list);
if(!check || list.length <=1){
return null;
}
else{

const listNumber = list.filter((element) => typeof element ==='number');
const listnumberOrdered = listNumber.sort((a, b) => a - b);
const pos = Math.floor(listnumberOrdered.length/2);

if(listNumber.length === 0){
return null;
}
else if(listnumberOrdered.length % 2 > 0){
return listnumberOrdered[pos];
}
else{
return listnumberOrdered[pos-1]+0.5;
}
}
}


module.exports = calculateMedian;
5 changes: 5 additions & 0 deletions Sprint-1/fix/median.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

const calculateMedian = require("./median.js");

// test("Calculate Median", () => {
// expect(calculateMedian([1, 2, 3])).toEqual(2);
// })


describe("calculateMedian", () => {
[
{ input: [1, 2, 3], expected: 2 },
Expand Down
Loading