[Tommy Collison] JavaScript-II - #251
Conversation
…minal for me, womp womp
John-Spraul
left a comment
There was a problem hiding this comment.
- Git stuff
- Completed Assignment
- Stretch Goal
Looks like you know what you're doing 👍
Let me know if the callback stuff is confusing 😖
| // firstItem passes the first item of the given array to the callback function. | ||
|
|
||
| return cb(arr); | ||
| } |
There was a problem hiding this comment.
firstItem should be doing the work, according to the instructions, so it should be cb(arr[0])
| function getLength(arr, cb) { | ||
| // getLength passes the length of the array into the callback. | ||
|
|
||
| return cb(arr); |
There was a problem hiding this comment.
getLength should do the work, so it should be cb(arr.length)
| function last(arr, cb) { | ||
| // last passes the last item of the array into the callback. | ||
|
|
||
| return cb(arr); |
| } | ||
|
|
||
| function lastitem(items, last) { | ||
| console.log(items[3]); |
There was a problem hiding this comment.
a better/more-dynamic way of accessing the last item in an array would be items[items.length - 1]
|
|
||
| function sumNums(x, y, cb) { | ||
| // sumNums adds two numbers (x, y) and passes the result to the callback. | ||
| return cb(x, y); |
|
|
||
| function multiplyNums(x, y, cb) { | ||
| // multiplyNums multiplies two numbers and passes the result to the callback. | ||
| return cb(x, y); |
| // contains checks if an item is present inside of the given array/list. | ||
| // Pass true to the callback if it is, otherwise pass false. | ||
|
|
||
| console.log(list.includes(item)); |
There was a problem hiding this comment.
you should pass list.includes(item) to your callback function
| let fullName = []; | ||
| console.log(fullName); | ||
|
|
||
| runners.forEach(function(combineNames) { |
There was a problem hiding this comment.
combineNames isn't a helpful placeholder for future readers
|
|
||
| // console.log(donationsList) | ||
|
|
||
| // Problem 2: Oh whoops, all of these people are actually named Jr. |
| tommyCounter += 1; | ||
| console.log(tommyCounter); | ||
| } | ||
|
|
There was a problem hiding this comment.
this isn't quite what they were looking for, should be something like:
const counter - () => {
let count = 0;
return () => ++count;
}
const addOne = counter();
addOne();
addOne();
👋 @John-Spraul