generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 153
London | ITP-May-2025 | Jamal Laqdiem| Module-Data-Groups | Sprint 1 #557
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
jemaljemy
wants to merge
15
commits into
CodeYourFuture:main
Choose a base branch
from
jemaljemy:sprint-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
301b0b4
fix(median): Correctly calculate median for all test cases
jemaljemy be12690
feat: Implement dedupe function and add tests.
jemaljemy 1038918
feat: Implement robust findMax function with comprehensive tests cove…
jemaljemy 95997b7
Adds a `sum` function that correctly sums finite numbers in an array,…
jemaljemy 849a7e8
Refactor the `includes` function to use a for .. of loop passing all …
jemaljemy 4a828b8
solve part 1 solution.
jemaljemy 171eef5
check status of the file
jemaljemy 0d44e9f
median.test file
jemaljemy dffbcb4
deleted a file
jemaljemy 0600b63
added the correct test file for calculateMedian function.
jemaljemy 9b0d9d6
Fix: replaced expect .toEqual using more concise .each to keep codes …
jemaljemy beb9e8e
Fix: deleted the extra lines.
jemaljemy 1b085dc
Merge branch 'CodeYourFuture:main' into sprint-1
jemaljemy 16245db
done
jemaljemy 0b91582
done
jemaljemy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
function dedupe() {} | ||
function dedupe(array) { | ||
const createSet = new Set() | ||
const newArray = [] | ||
if(!Array.isArray(array) || array.length ===0) { | ||
return [] | ||
} | ||
for (let i = 0 ; i < array.length; i++) { | ||
const element = array[i] | ||
if (!createSet.has(element)) { | ||
createSet.add(element) | ||
newArray.push(element) | ||
} | ||
} | ||
return newArray | ||
} | ||
|
||
console.log(dedupe([1,3,4,3,3,1,6,6])) | ||
console.log(dedupe([1,3,4,6,7,8])) | ||
console.log(dedupe(['a','a','a','c','c','g','g',5,5])) | ||
|
||
module.exports = dedupe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
function findMax(elements) { | ||
let max = -Infinity | ||
for( let i = 0 ; i < elements.length; i++) { | ||
const checkElements = elements[i] | ||
if(typeof checkElements === "number" && Number.isFinite(checkElements)) { | ||
if(checkElements > max){ | ||
max = checkElements | ||
} | ||
} | ||
} | ||
return max | ||
|
||
} | ||
|
||
console.log(findMax([2,5,4,1,8])) | ||
console.log(findMax([2,5,4,8,1,,'b','j'])) | ||
console.log(findMax([])) | ||
console.log(findMax([3])) | ||
console.log(findMax([-1,-5,-9-150])) | ||
console.log(findMax([0.1,0.100,0.5])) | ||
console.log(findMax([2,5,-4,4,-1,1,10])) | ||
console.log(findMax(['a','n','/','+'])) | ||
|
||
module.exports = findMax; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
function sum(elements) { | ||
|
||
let filterNumbers = elements.filter( | ||
(element) => typeof element === "number" && Number.isFinite(element) | ||
); | ||
if (filterNumbers.length === 0) { | ||
return 0; | ||
} | ||
const sumTotal = filterNumbers.reduce((acc, num) => acc + num); | ||
illicitonion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return sumTotal; | ||
} | ||
|
||
console.log(sum([1, 5, 8, 3])); | ||
console.log(sum([-1, -40, -10, -3])); | ||
console.log(sum([])); | ||
console.log(sum([50])); | ||
console.log(sum(["a", 4, "/", 6, "+"])); | ||
console.log(sum(["r", ")", "}", "#"])); | ||
console.log(sum([0.5, 0.7, 0.5, 0.9])); | ||
module.exports = sum; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
// Refactor the implementation of includes to use a for...of loop | ||
|
||
function includes(list, target) { | ||
for (let index = 0; index < list.length; index++) { | ||
const element = list[index]; | ||
if (element === target) { | ||
|
||
for (const item of list) { | ||
if (item === target) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
console.log(includes([5, 6, null], 4)); | ||
console.log(includes(["a", "b", "m"], "m")); | ||
console.log(includes(["a", "b", "m"], 2)); | ||
console.log(includes([1, 2, 2, 3], 2)); | ||
console.log(includes([null], null)); | ||
console.log(includes([], 2)); | ||
|
||
module.exports = includes; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const inputFilePath = path.join(__dirname, 'input.txt'); | ||
|
||
const inputString = fs.readFileSync(inputFilePath, 'utf8'); | ||
|
||
function solvePart1(inputString) { | ||
const changes = inputString.trim().split('\n').filter(line => line.length > 0); | ||
const numericChanges = changes.map(change => Number(change)); | ||
let currentFrequency = 0; | ||
|
||
for (const change of numericChanges) { | ||
currentFrequency += change; | ||
} | ||
|
||
return currentFrequency; | ||
} | ||
|
||
const finalFrequency = solvePart1(inputString); | ||
console.log(finalFrequency); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.