ES6 - Write Higher Order Arrow Functions - About Chaining, Needs Clarification
See original GitHub issueDescribe your problem and - if possible - how to reproduce it
Challenge ES6 - Write Higher Order Arrow Functions
The examples show moving from normal function
to the ES6 arrow function. However, the challenge is about “chaining” multiple functions together. It is super unclear how the example code would lead one to chaining a filter and map function together. This is really a better discussion for the functional programming section.
Additionally, the filter function requires that users understand how to determine if a number is an integer or not. There is nothing in the prior curriculum which would make it clear to a new coder how to do this. While you do talk about the “parseInt” function, it’s never used in the context of comparing a number to itself. A better filter function might be “positive numbers” instead, which is a much simpler comparison.
I was attempting to help someone understand this one today and I was initially flummoxed as to how to solve it.
Once I realized it was about chaining, I was able to write a solution like this:
const squaredIntegers = arr
.filter(elem => elem == parseInt(elem))
.map(elem => elem * elem);
I don’t believe that there is another way to solve this using higher order functions and arrow functions. There is no solution in the seed file, so I’m not sure exactly what the authors had in mind.
In short, this challenge badly needs clarification and simplification. It may be entirely inappropriate for this section of challenges. I could see it after a new challenge called “How to Chain Higher Order functions” or something like that.
Add a Link to the page with the problem
Issue Analytics
- State:
- Created 5 years ago
- Reactions:16
- Comments:31 (17 by maintainers)
Top GitHub Comments
I just reviewed the curriculum leading up to this challenge.
All told, I think this challenge should just be removed or moved to the functional programming section.
I would agree with this issue - I got real stuck on it knowing quite well how to use the array methods - it doesn’t say anything about using
.map
and it is not used or taught at all up to this point - same with testing if it’s an integer - that’s not too tough to figure out I don’t think, but it does complicate things - the challenge description only talks about using.filter
and the instructions say…From those instructions it seems like the challenge wants you to use just
.filter
to accomplish this - challenges are supposed to teach a single thing, this one introduces too much and feels way too complicated - and it isn’t clear to me what we are even supposed to be learning on this one