Ryan Walker - JavaScript-II - #362
Open
rytwalker wants to merge 6 commits into
Open
Conversation
| console.log(`Total donations: $${ticketPriceTotal}`); | ||
|
|
||
| // ==== Challenge 5: Be Creative ==== | ||
| // Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above. |
There was a problem hiding this comment.
Great job with the creativity here!
| }); | ||
|
|
||
| // Arrow Function | ||
| last(items, lastItem => console.log(lastItem)); |
There was a problem hiding this comment.
how about this? last(items, console.log)
|
|
||
| function contains(item, list, cb) { | ||
| // contains checks if an item is present inside of the given array/list. | ||
| // Pass true to the callback if it is, otherwise pass false. |
There was a problem hiding this comment.
this one has a different pattern from the others. Read carefully what it's asking, and compare to the solution code
function contains(item, list, cb) {
// contains checks if an item is present inside of the given array/list.
// Pass true to the callback if it is, otherwise pass false.
for (let i = 0; i < list.length; i++) {
if (list[i] === item) {
return cb(true);
}
}
return cb(false);
}
| // removeDuplicates removes all duplicate values from the given array. | ||
| // Pass the duplicate free array to the callback function. | ||
| // Do not mutate the original array. | ||
| const noDoubles = array.filter((item, index) => array.indexOf(item) >= index); |
| }; | ||
| return counter; | ||
| }; | ||
|
|
There was a problem hiding this comment.
excellent, looks like you're locked in on closures if you get this one
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.
@kamry-bowman