Repository navigation
Conversation
OmarSalah95
left a comment
There was a problem hiding this comment.
Good overall work using the logic and applying the callbacks and so on, I have noticed your naming convention has gotten abit crazy, with functions call haha, and parameters called lol.
You need to keep your naming conventions consistent so that when other devs reading your code can make sense of it.
Don't forget when it comes to parameters. you can use the same name in multiple functions. So if you have a filter, map, and reduce in 3 separate spots, and they all iterate through the same runners array, just have all of the parameters (aka place holders) be runner, there is no need to invent new non descriptive placeholders
|
|
||
| let fullName2 = [] | ||
| runners.forEach(runner => fullName2.push(`${runner.first_name} ${runner.last_name}`)) | ||
| console.log(fullName2); |
There was a problem hiding this comment.
Great job using Template string literals here to render the name information from the runner object. This could also be done using string concatenation as well.
| runners.forEach(addName) | ||
|
|
||
| function addName(word){ | ||
| fullName4.push(`${word.first_name} ${word.last_name}`) |
There was a problem hiding this comment.
Nice abstracting the callback into its own function rather than typing it in the forEach callback.
| // for (let i = 0; i < runners.length; i++) { | ||
| // fullName.push(runners[i].first_name + " " + runners[i].last_name) | ||
| // } | ||
| // console.log(fullName) |
There was a problem hiding this comment.
I like seeing that you got both syntax's here.
|
|
||
| function allCapMode (words) { | ||
| return words.first_name.toUpperCase() | ||
| // allCaps.push(`${wubba.first_name}`) |
There was a problem hiding this comment.
Glad to see it looks like you have a fairly solid grasp on callbacks now!
|
|
||
|
|
||
| let largeShirts = runners.filter(shirts).map(names) | ||
|
|
There was a problem hiding this comment.
Nice use of Method chaining here, using dual abstracted callback functions stored in the global scope as their arguments!
| function names(xxx) { | ||
| return xxx.first_name + " - " + xxx.shirt_size | ||
| } | ||
|
|
There was a problem hiding this comment.
Naming convention! what is the xxx supposed to be a place holder for? is it not each item in the array we are mapping through?
Because of method chaining we. in this case, are iterating through the freshly filtered array of runners with a shirt size of large.
So this xxx parameter is a place holder for a runner object who already meets the conditions of being a large shirt size wearer
|
|
||
| function sums(x, y) { | ||
| return x + y.donation | ||
| } |
There was a problem hiding this comment.
In reducers, you are better off sticking to keeping the actual callback inside of your reduce and in 1 unit.
|
|
||
| function tally (jolly) { | ||
| return jolly.donation | ||
| } |
| function dollars (cash) { | ||
| cashflow.push(`To: ${cash.email} <br><br> Hello, Mr or Ms ${cash.first_name} ${cash.last_name}, we have an exciting offer for you today`) | ||
| } | ||
|
|
There was a problem hiding this comment.
the breaks are HTML tags not JS .
| function haha(lol) { | ||
| if (lol.donation > 150) | ||
| return lol.first_name + lol.last_name + lol.email + lol.donation | ||
| } |
There was a problem hiding this comment.
What is happening here with these names?!?!
Hard stuff. Could have easily spent an entire day on callbacks alone, or array methods alone.