Completed JS-II - #1
Conversation
ayunas
left a comment
There was a problem hiding this comment.
@ashafranchi doing a great job asha. keep it up. and if you can get to the stretch assignments that'll be amazing.
| runners.map((runner) => { | ||
| allCaps.push(runner.first_name.toUpperCase()); | ||
| }); | ||
|
|
There was a problem hiding this comment.
this works, but because map returns a new array, just set the runners.map = a varaible, and you don't have to push to allCaps. the way you did it, a forEach() makes more sense to use. with map, it returns a new array.
| return total + runners.donation; | ||
| }, 0); | ||
|
|
||
| ticketPriceTotal.push(donationTotal); |
There was a problem hiding this comment.
probably not necessary to push the donationTotal value into an array. what's the point of having a single value in an array?
| // List all emails | ||
| let ListEmail = []; | ||
| runners.forEach(function(runner) { | ||
| ListEmail.push(runner.email); |
There was a problem hiding this comment.
usually capital variables refer to constructor functions. so i would keep it lowercase.
| function last(arr, cb) { | ||
| // last passes the last item of the array into the callback. | ||
| // last passes the last item of the array into the callback. | ||
| return cb(arr.pop()); |
There was a problem hiding this comment.
good use of .pop here to get the last item.
| test = true; | ||
| } | ||
| } | ||
| return cb(test); |
There was a problem hiding this comment.
nice classic way of searching for the item.
| function returnsayHi() { | ||
| return sayHi; | ||
| } | ||
| returnsayHi(); |
There was a problem hiding this comment.
this is a closure in the very basic sense of the word, because the function is reaching outside it's scope and storing it's value inside it's execution context. Usually, when we return a nested function inside another function, we see a better use case for closures.
No description provided.