If you have no coding experience and is just beginning with FCC's Javascript section, I suggest you read this first. (regarding es6 section)

Tell us what’s happening:
After you finish the section Basic Javascript, you head into ES6 section. Do the exercises until you reach this particular challenge, “Write Higher Order Arrow Functions”. After this, head on to the next section which I believe is Regular Expressions if I remember correctly.

With this challenge, you are asked to use 3 higher order functions using a new syntax without even discussing what higher order functions are. The example is also not good:

FBPosts.filter(function(post) {
return post.thumbnail !== null && post.shares > 100 && post.likes > 500;
})

You see the example given refers to an imaginary object, but for beginners, letting us see that object AND the new array resulting from the use of the higher order function is very important to get a hold of this new higher order function .filter() then it proceeds to ask you to use .reduce .filter and .map.

I am not a good coder, when I encountered this challenge I was just stumped and I stopped coding for about a week in frustration. If you are a good coder unlike me, then I still think you should skip this part for a very simple reason, it’s going to be discussed anyway with better structure, challenges, examples and explanations.

I finished the 2nd to last section of FCC Javascript just before the projects for certification and I returned to this part, I did it in less than 10 minutes. It’s still not fast considering the average JS coder, but it’s way better than a week and I was able to do it because unlike this section, the rest of the sections in Javascript actually makes sense.

So really, save yourself, save yourself time and/or frustration and once you hit this, do the next section and come just come back.
Your code so far




const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
const squareList = (arr) => {
  "use strict";
  // change code below this line
  const squaredIntegers = arr.filter((int)=>Number.isInteger(int) && int > 0).map((e)=>e*e);
  // change code above this line
  return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-higher-order-arrow-functions

1 Like