finished callbacks - #1
Open
SirAndrewDillon wants to merge 3 commits into
Open
Conversation
Ian84Be
reviewed
May 8, 2019
| // } | ||
| // console.log(fullName); | ||
|
|
||
| runners.forEach(function(names){ |
Collaborator
There was a problem hiding this comment.
perfect way to do this. you could also refactor this to ES6 fat arrow syntax.
runners.forEach(names =>
fullName.push(`${names.first_name} ${names.last_name}`)
);
| // The large shirts won't be available for the event due to an ordering issue. Get a list of runners with large sized shirts so they can choose a different size. Return an array named largeShirts that contains information about the runners that have a shirt size of L and log the result | ||
| let largeShirts = []; | ||
|
|
||
| largeShirts = runners.filter(shirt => shirt.shirt_size === 'L') |
Collaborator
There was a problem hiding this comment.
excellent use of the fat arrow.
| // 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 = []; | ||
|
|
||
| ticketPriceTotal = runners.reduce(function(ticket,item){ |
Collaborator
There was a problem hiding this comment.
this could also be refactored into ES6
ticketPriceTotal = runners.reduce((ticket,item) =>
ticket += item.donation, 0);
| // ==== Challenge 1: Write your own closure ==== | ||
| // Write a simple closure of your own creation. Keep it simple! | ||
|
|
||
| function sayHello(name) { |
Collaborator
There was a problem hiding this comment.
good job with this. you could also strip it down a bit more, the template literal does not require parens, and you can drop the curly braces from the say function.
function sayHello(name) {
const text = `Hello ${name}`;
const say = () => console.log(text);
say();
}
| const counter = () => { | ||
| // Return a function that when invoked increments and returns a counter variable. | ||
| let count = 0; | ||
| return(function() { return( ++count); }) |
Collaborator
There was a problem hiding this comment.
great job making use of javascript closure.
again you could make use of the ES6 syntax to clean up this function
const counter = () => {
let count = 0;
return () => ++count;
}
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.