-
Notifications
You must be signed in to change notification settings - Fork 328
Conversation
Done and changed all the requirements |
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.
Hi @mohamdmahdi, you code contains confusing variable and parameter names. Can you please go through the comments and improve them?
@@ -45,17 +45,33 @@ const tuesday = [ | |||
const maartjesTasks = monday.concat(tuesday); | |||
const maartjesHourlyRate = 20; | |||
|
|||
function computeTasksInHours(maartjesTasksX, celling) { |
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 this X
means. A better solution would be to name this parameter simply tasks
. 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 name threshold
is the accurate name to use.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
As I indicated in an earlier comment, the name marrtje
has a spelling error. Her name is maartje
.
function computeTasksInHours(maartjesTasksX, celling) { | ||
const marrtjeTasksInHours = maartjesTasksX | ||
.map(task => task.duration / 60) | ||
.filter(task => task >= celling); |
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.
The result of mapping tasks to hours is an array of hours. Therefore you are filtering hours
here and a single element of an hours
array is an hour
:
.filter(hour => hour >= threshold);
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 comment
The 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).
for (const task of Taskhours) { | ||
const Total = task * hourlyRate; | ||
rate += Total; | ||
} |
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.
Since we're concerned here with practicing array methods, why don't you try a .reduce()
(preferred) or .forEach()
here?
const Taskhours = computeTasksInHours(tasks, 2); | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Total
-> total
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
The anonymous (arrow) function that you pass as an argument to the filter
method should return a boolean (i.e. true
or false
. In your case you are return false
or the number itself. It still works because zero is 'falsy' and non-zero is 'truthy', but that is just sheer luck. Can you fix this by letting the function return a genuine boolean at all times?
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.
Hi @mohamdmahdi, I still see various comment unaddressed.
hi @mohamdmahdi can you please address @remarcmij 's comments? |
Week 2 homework