-
Notifications
You must be signed in to change notification settings - Fork 0
finished callbacks #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job working through these. remember to make use of your ES6 syntax to keep your functions uncluttered.
// } | ||
// console.log(fullName); | ||
|
||
runners.forEach(function(names){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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}`)
);
console.log(allCaps); | ||
|
||
// ==== Challenge 3: Use .filter() ==== | ||
// 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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could also be refactored into ES6
ticketPriceTotal = runners.reduce((ticket,item) =>
ticket += item.donation, 0);
@@ -1,21 +1,43 @@ | |||
// ==== Challenge 1: Write your own closure ==== | |||
// Write a simple closure of your own creation. Keep it simple! | |||
|
|||
function sayHello(name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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();
}
|
||
/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */ | ||
|
||
|
||
// ==== Challenge 2: Create a counter function ==== | ||
const counter = () => { | ||
// Return a function that when invoked increments and returns a counter variable. | ||
let count = 0; | ||
return(function() { return( ++count); }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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;
}
No description provided.