Meera andersen - #1
Open
meera-andersen wants to merge 2 commits into
Open
Conversation
clem9281
reviewed
May 8, 2019
| // 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){ |
Collaborator
There was a problem hiding this comment.
Suggested change
| 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); |
Collaborator
There was a problem hiding this comment.
Suggested change
| // 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); |
Collaborator
There was a problem hiding this comment.
Suggested change
| // 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"); |
Collaborator
There was a problem hiding this comment.
Suggested change
| 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){ |
Collaborator
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finished all challenges