-
Notifications
You must be signed in to change notification settings - Fork 328
Mohammed Mahdi homework week2 #229
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,17 +45,33 @@ const tuesday = [ | |
const maartjesTasks = monday.concat(tuesday); | ||
const maartjesHourlyRate = 20; | ||
|
||
function computeTasksInHours(maartjesTasksX, celling) { | ||
const marrtjeTasksInHours = maartjesTasksX | ||
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. As I indicated in an earlier comment, the name |
||
.map(task => task.duration / 60) | ||
.filter(task => task >= celling); | ||
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. The result of mapping tasks to hours is an array of hours. Therefore you are filtering .filter(hour => hour >= threshold); |
||
return marrtjeTasksInHours; | ||
} | ||
|
||
function computeEarnings(tasks, hourlyRate) { | ||
// Replace this comment and the next line with your code | ||
console.log(tasks, hourlyRate); | ||
const Taskhours = computeTasksInHours(tasks, 2); | ||
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. Variable, function and parameter names should be in camelCase (start with a lowercase letter). See [Naming conventions)(https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md). |
||
let rate = 0; | ||
for (const task of Taskhours) { | ||
const Total = task * hourlyRate; | ||
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.
|
||
rate += Total; | ||
} | ||
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. Since we're concerned here with practicing array methods, why don't you try a |
||
return rate; | ||
// eslint-disable-next-line no-unused-vars | ||
} | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); | ||
const result = earnings.toFixed(2); | ||
|
||
// Math.round(rate * 100) / 100; | ||
|
||
// add code to convert `earnings` to a string rounded to two decimals (euro cents) | ||
|
||
console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`); | ||
console.log('Maartje has earned €' + result + '.'); | ||
|
||
// Do not change or remove anything below this line | ||
module.exports = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ | |
|
||
function doubleOddNumbers(numbers) { | ||
// Replace this comment and the next line with your code | ||
console.log(numbers); | ||
const newNumber = numbers.filter(number => (number % 2 === 1 ? number : false)).map(x => x + x); | ||
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. The anonymous (arrow) function that you pass as an argument to the |
||
return newNumber; | ||
} | ||
|
||
const myNumbers = [1, 2, 3, 4]; | ||
console.log(doubleOddNumbers(myNumbers)); | ||
console.log('Using the filter method :' + doubleOddNumbers(myNumbers)); | ||
|
||
// Do not change or remove anything below this line | ||
module.exports = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably added an
X
to this variable name because of an ESLint error about shadowing a variable name. While this solved your problem you have now put the onus on the reader of your code to find out what thisX
means. A better solution would be to name this parameter simplytasks
. It also correctly implies that this function can use to compute the task in hours for *any tasks array, not only the one of Maartje.The parameter
celling
is misspelling (ceiling
) and also incorrect because it implies a maximum value, whereas here we are concerned with a minimum value. So the namethreshold
is the accurate name to use.