Skip to content

[Tommy Collison] JavaScript-II - #251

Open
tommycollison wants to merge 9 commits into
bloominstituteoftechnology:masterfrom
tommycollison:master
Open

[Tommy Collison] JavaScript-II#251
tommycollison wants to merge 9 commits into
bloominstituteoftechnology:masterfrom
tommycollison:master

Conversation

@tommycollison

Copy link
Copy Markdown

@John-Spraul John-Spraul left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Git stuff
  • Completed Assignment
  • Stretch Goal

Looks like you know what you're doing 👍
Let me know if the callback stuff is confusing 😖

Comment thread assignments/callbacks.js
// firstItem passes the first item of the given array to the callback function.

return cb(arr);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firstItem should be doing the work, according to the instructions, so it should be cb(arr[0])

Comment thread assignments/callbacks.js
function getLength(arr, cb) {
// getLength passes the length of the array into the callback.

return cb(arr);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLength should do the work, so it should be cb(arr.length)

Comment thread assignments/callbacks.js
function last(arr, cb) {
// last passes the last item of the array into the callback.

return cb(arr);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cb(arr[arr.length -1])

Comment thread assignments/callbacks.js
}

function lastitem(items, last) {
console.log(items[3]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better/more-dynamic way of accessing the last item in an array would be items[items.length - 1]

Comment thread assignments/callbacks.js

function sumNums(x, y, cb) {
// sumNums adds two numbers (x, y) and passes the result to the callback.
return cb(x, y);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cb(x + y)

Comment thread assignments/callbacks.js

function multiplyNums(x, y, cb) {
// multiplyNums multiplies two numbers and passes the result to the callback.
return cb(x, y);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cb(x * y)

Comment thread assignments/callbacks.js
// 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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should pass list.includes(item) to your callback function

let fullName = [];
console.log(fullName);

runners.forEach(function(combineNames) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combineNames isn't a helpful placeholder for future readers


// console.log(donationsList)

// Problem 2: Oh whoops, all of these people are actually named Jr.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

Comment thread assignments/closure.js
tommyCounter += 1;
console.log(tommyCounter);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants