-
Notifications
You must be signed in to change notification settings - Fork 0
5-7-19 Javascript II project #1
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: master
Are you sure you want to change the base?
Conversation
OmarSalah95
left a comment
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | ||
| } |
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.
Naming convention.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is happening here with these names?!?!
Hard stuff. Could have easily spent an entire day on callbacks alone, or array methods alone.