Repository navigation
Meera andersen - #1
meera-andersen wants to merge 2 commits into
Conversation
clem9281
left a comment
There was a problem hiding this comment.
2:star:
Fantastic job, really solid work. I had a couple of suggestions, but overall it looks great!
| // The event director needs both the first and last names of each runner for their running bibs. Combine both the first and last names into a new array called fullName. | ||
| let fullName = []; | ||
| console.log(fullName); | ||
| let fullName = runners.forEach(function(currentValue){ |
There was a problem hiding this comment.
| let fullName = runners.forEach(function(currentValue){ | |
| runners.forEach(function(currentValue){ |
forEach has no return value, unlike map.
| let fullName = []; | ||
| console.log(fullName); | ||
| let fullName = runners.forEach(function(currentValue){ | ||
| // console.log(currentValue.first_name, currentValue.last_name); |
There was a problem hiding this comment.
| // console.log(currentValue.first_name, currentValue.last_name); | |
| fullName.push(`${currentValue.first_name} ${currentValue.last_name}`); |
So since forEach doesn't have a return value, we have to manually populate the fullName array
| // console.log(currentValue.first_name, currentValue.last_name); | ||
| }); | ||
|
|
||
| // console.log(fullName); |
There was a problem hiding this comment.
| // console.log(fullName); | |
| console.log(fullName); |
Right now this is undefined, after you follow my suggestion it should contain the correct answer
|
|
||
|
|
||
| // Problem 3 | ||
| let fidel = runners.filter(currentValue => currentValue.last_name === "Fidel"); |
There was a problem hiding this comment.
| let fidel = runners.filter(currentValue => currentValue.last_name === "Fidel"); | |
| let fidel = runners.filter(currentValue => currentValue.first_name === "Fidel"); |
Fidel is someone's first name in the array
|
|
||
| function getLength(arr, cb) { | ||
| // getLength passes the length of the array into the callback. | ||
| const length = function(array){ |
There was a problem hiding this comment.
So they were looking for these questions to be answered in a little bit of a different format than what you have here, but you correctly demonstrated using HOFs with callbacks
Finished all challenges