-
-
Notifications
You must be signed in to change notification settings - Fork 153
London | ITP-May-2025 | Sisay Mehari | Module-Data-Groups | Sprint 1 #556
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
base: main
Are you sure you want to change the base?
Changes from all commits
bd8b615
240a7f6
4bf77a8
d3bcf23
a33ef42
5fed4b4
ca2220e
26e8cd8
bcdcfb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests passed, well done |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tests passed, well done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
function dedupe() {} | ||
function dedupe(list) { | ||
const unique = [...new Set(list)]; | ||
return unique; | ||
} | ||
|
||
// console.log(dedupe(['apple', 'banana', 'apple', 1, 2, 1])); | ||
|
||
|
||
|
||
|
||
module.exports = dedupe; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
function findMax(elements) { | ||
const filtered = elements.filter(elements => typeof elements === "number" && !isNaN(elements)) | ||
const max = Math.max(...filtered); | ||
return max; | ||
} | ||
|
||
|
||
|
||
console.log(findMax(['apple', 'banana', null, undefined])); | ||
module.exports = findMax; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests passed, well done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
function sum(elements) { | ||
const filtered = elements.filter(elements => typeof elements === "number" && !isNaN(elements) ); | ||
if (filtered.length === 0) { | ||
return 0; | ||
}else { | ||
const sumTotal = filtered.reduce((total, elements) => total + elements, 0); | ||
return sumTotal; | ||
} | ||
} | ||
|
||
module.exports = sum; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests passed, well done |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code looks fine |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider how you would code to catch errors such as file not being available. just a consideration, w3 schools is a website with good information There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would work, well done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each type of error can be identified and returned however that should be discussed later in the course. Do your own research in the meantime. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const fs = require('fs'); | ||
|
||
const filePath = 'input.txt'; | ||
try { | ||
const content = fs.readFileSync(filePath, 'utf8'); | ||
const frequencyChanges = content | ||
.split('\n') | ||
.filter(line => line.trim() !== '') | ||
.map(str => parseInt(str, 10)); | ||
|
||
|
||
const total = frequencyChanges.reduce((a, b) => a + b, 0); | ||
|
||
console.log('Total frequency:', total); | ||
}catch (err) { | ||
console.error('Error reading file:', err); | ||
} |
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.