Open
Conversation
blokboy
reviewed
Apr 22, 2019
assignments/callbacks.js
Outdated
|
|
||
| function last(arr, cb) { | ||
| // last passes the last item of the array into the callback. | ||
| return cb(arr.pop()); |
Collaborator
There was a problem hiding this comment.
.pop() actually modifies the array by removing the last element it returns. Is this desired behavior?
blokboy
reviewed
Apr 22, 2019
| 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. | ||
| return cb(list.includes(item)); |
Owner
Author
|
Changed it to this. It shouldn’t modify the original array.
function last(arr, cb) {
// last passes the last item of the array into the callback.
return cb(arr[arr.length - 1]);
};
last(items, (end) => {
console.log(end);
});
From: Jordan Marsaw <notifications@github.com>
Sent: Monday, April 22, 2019 6:28 PM
To: cladams0203/JavaScript-II <JavaScript-II@noreply.github.com>
Cc: chris adams <cladams0203@gmail.com>; Author <author@noreply.github.com>
Subject: Re: [cladams0203/JavaScript-II] Christopher adams (#1)
@blokboy commented on this pull request.
_____
In assignments/callbacks.js <#1 (comment)> :
}
function last(arr, cb) {
// last passes the last item of the array into the callback.
+ return cb(arr.pop());
.pop() actually modifies the array by removing the last element it returns. Is this desired behavior?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#1 (review)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AJ42CUC3AUMO3U3IH5ZJIRLPRY3YJANCNFSM4HHIWTQA> . <https://github.com/notifications/beacon/AJ42CUFOJFBQWROUGXAFZK3PRY3YJANCNFSM4HHIWTQA.gif>
|
blokboy
reviewed
Apr 22, 2019
|
|
||
| // ==== Challenge 4: Use .reduce() ==== | ||
| // The donations need to be tallied up and reported for tax purposes. Add up all the donations into a ticketPriceTotal array and log the result | ||
| let ticketPriceTotal = []; |
Collaborator
There was a problem hiding this comment.
See if you can turn 82-85 into one line
Hint: let ticketPriceTotal = runners.reduce(...) it returns a single value but you can cast it to an array multiple ways
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.
No description provided.