-
Notifications
You must be signed in to change notification settings - Fork 0
higherOreder #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
higherOreder #16
Conversation
stu-k
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map works, but your naming of the variables inside is misleading, filter is perfect, and forEach is a mess. I don't think this is your latest version of this project!
06week/higherOrder.js
Outdated
| const forEach = (inputArray, inputFunction) => { | ||
| const anotherArr = []; | ||
| for (let i = 0; i < inputArray.length; i++){ | ||
| anotherArr.push(inputFunction(inputArray[i])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushing to an array that isn't returned, then logging the length. This isn't what forEach() does.
06week/higherOrder.js
Outdated
| // return anotherArr; | ||
| }; | ||
| const fullArray = [1, 2, 3]; | ||
| const inputFunction = i => fullArray.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop using .length everywhere, you don't need it.
| // } | ||
| const map = (arg1, arg2) => { | ||
| let nums = []; | ||
| arg1.forEach(index => nums.push(arg2(index))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This map function works perfectly, but some of the things inside aren't named well. index isn't the index, it's the item, and the return array won't always be full of numbers, so nums doesn't make sense. But it works!
| if(inFun(inpt[i])) { | ||
| arr1.push(inpt[i]); | ||
| } | ||
| }return arr1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the return on its own line.
Checkpoint Rubric
This is the rubric that your instructor will use to grade your checkpoints. Please do not edit.
Checkpoint 1
Checkpoint 2
Checkpoint 3