Skip to content

London | 25-ITP-May | Houssam Lahlah | Sprint 3 | Quote-Generator #748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b06cb19
Add mean calculation test
HoussamLh Jul 25, 2025
c9fbbff
Add test for calculateMedian and calculateMean using salaries array
HoussamLh Jul 25, 2025
95f7fd3
Add calculateMedian function with tests for even and odd length arrays
HoussamLh Jul 25, 2025
f02e624
I've done the prep of this sprint 2
HoussamLh Jul 30, 2025
c87010e
access houseNumber property correctly instead of using index
HoussamLh Jul 30, 2025
0b3bd51
iterate over object values correctly to log all properties
HoussamLh Jul 30, 2025
5c03c87
correctly log recipe ingredients on separate lines
HoussamLh Jul 30, 2025
9059809
implement 'contains' function to check property existence in objects
HoussamLh Jul 30, 2025
a0ec1e9
add 'createLookup' function scaffold and test placeholder
HoussamLh Jul 30, 2025
32172e4
- improve 'parseQueryString' function to handle '=' in values correctly
HoussamLh Jul 30, 2025
5b4d5eb
- implement 'tally' function to count frequencies in an array
HoussamLh Jul 30, 2025
a107cbb
- correct property access in address object logging
HoussamLh Jul 30, 2025
1403fb7
- iterate over object values correctly in author.js
HoussamLh Jul 30, 2025
f88fb4e
- Properly log recipe ingredients on separate lines
HoussamLh Jul 30, 2025
1f315ef
- correct invert function to swap object keys and values
HoussamLh Jul 31, 2025
8b66d38
- implement countWords function with punctuation removal and case ins…
HoussamLh Jul 31, 2025
629e898
- split calculateMode into getFrequencies and findMode helper functions
HoussamLh Jul 31, 2025
429338b
- correctly calculate totalTill by parsing coin strings
HoussamLh Jul 31, 2025
fdc625c
- improve calculateMedian to handle filtering, sorting, and edge cases
HoussamLh Jul 31, 2025
dbdc57d
- Implement dedupe function and add tests
HoussamLh Jul 31, 2025
8f0fe97
- Implement findMax function and add comprehensive tests
HoussamLh Jul 31, 2025
faf9844
- Implement sum function with tests
HoussamLh Jul 31, 2025
c83edb4
- Refactored the includes function to use a for...of loop instead of
HoussamLh Jul 31, 2025
5d17583
- Implement solution for Advent of Code Day 1:
HoussamLh Jul 31, 2025
d7340c3
Fix alarm countdown and audio playback so all tests pass
HoussamLh Jul 31, 2025
2efa970
- update button text to match test expectation ("New quote")
HoussamLh Jul 31, 2025
51ac422
- implement readingList function to display books with image, title, …
HoussamLh Jul 31, 2025
ed750dc
- update button IDs to match test requirements for automatic slidesho…
HoussamLh Jul 31, 2025
4aaab8f
- Adds a number input field for user-defined delay.
HoussamLh Jul 31, 2025
6abc993
- update script.js to use correct input ID 'todoInput' and add event …
HoussamLh Jul 31, 2025
d10b9e4
Merge branch 'CodeYourFuture:main' into Build-quote-generator
HoussamLh Aug 6, 2025
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
22 changes: 19 additions & 3 deletions Sprint-1/fix/median.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,25 @@
// 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;
if (!Array.isArray(list)) return null;

// Filter to keep only numbers
const numbers = list.filter(item => typeof item === "number");

if (numbers.length === 0) return null;

// Sort numbers ascending (without modifying original array)
const sorted = [...numbers].sort((a, b) => a - b);

const mid = Math.floor(sorted.length / 2);

if (sorted.length % 2 !== 0) {
// Odd length, return middle value
return sorted[mid];
} else {
// Even length, return average of two middle values
return (sorted[mid - 1] + sorted[mid]) / 2;
}
}

module.exports = calculateMedian;
Loading