Skip to content

Humberto Raya Javascript-II - #304

Open
hraya wants to merge 6 commits into
bloominstituteoftechnology:masterfrom
hraya:master
Open

Humberto Raya Javascript-II#304
hraya wants to merge 6 commits into
bloominstituteoftechnology:masterfrom
hraya:master

Conversation

@hraya

@hraya hraya commented Aug 18, 2018

Copy link
Copy Markdown

@clarakosi clarakosi 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.

Great work, Humberto! 👍

I did leave a few comments about how you could improve your code.

Comment thread assignments/callbacks.js
function firstItem(arr, cb) {
// firstItem passes the first item of the given array to the callback function.
for(let i = 0; i < arr.length; i++) {
if (arr[i] === arr[0]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since i is starting at 0 arr[i] will be equivalent to arr[0]. The first element in the array will always be at arr[0]. So there was no need for this for loop. You could just pass arr[0] to the callback.

Comment thread assignments/callbacks.js
last(items, lastItem)

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great solution but the function should have passed the sum to the callback. The same for the other 2 problems below it.

Comment thread assignments/closure.js
return `I am ${nickname} from the states! and you?`
}

console.log(introduceSelf());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider rewriting these with return instead of console.log

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