Aislynn edmiston - #1
Conversation
| // 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 = []; | ||
|
|
||
| runners.forEach(function firstAndLastName(element) { |
There was a problem hiding this comment.
I'd recommend naming "element" what it is so the code is more semantic. In this case, each element is a "runner." Similarly, your variable "i" could be called "names" so that the logic is a bit easier to follow. Typically, "i" refers to an index.
| ticketPriceTotal.push(runner.donation); | ||
| }) | ||
|
|
||
| console.log(ticketPriceTotal.reduce(function (pv, cv, ci, arr){ |
| }) | ||
|
|
||
| // Problem 3 No newline at end of file | ||
| console.log(sorted.sort()); No newline at end of file |
There was a problem hiding this comment.
Nice work on these three problems!
| return cb(arr.length); | ||
| } | ||
|
|
||
| getLength(items, function(first){ |
There was a problem hiding this comment.
The naming of the argument "first" is a bit confusing here.
|
|
||
| function last(arr, cb) { | ||
| // last passes the last item of the array into the callback. | ||
| return cb(arr.slice(-1).pop()); |
There was a problem hiding this comment.
Nice! You can also use arr[arr.length-1]
| return cb (list.includes(item)); | ||
| } | ||
|
|
||
| contains( 'rock', items, console.log); |
There was a problem hiding this comment.
Nice work on all these callbacks!
| // ==== Challenge 1: Write your own closure ==== | ||
| // Write a simple closure of your own creation. Keep it simple! | ||
|
|
||
| function dateOfBirth(month, day, year){ |
There was a problem hiding this comment.
This is a great start. I noticed your console.log is a bit off and you're not using myBirth, though. Here's how it looks with those fixed:
function dateOfBirth(month, day, year){
const myBirth = "The date of my birth is:";
function myBirthday (){
return `${myBirth} ${month} ${day}, ${year}`;
}
return myBirthday();
}
console.log(dateOfBirth("May", "15", '1993'));
| const counter = () => { | ||
| // Return a function that when invoked increments and returns a counter variable. | ||
| let count = 0; | ||
| return () => (++count); |
No description provided.