Write Higher Order Arrow Functions =>

Tell us what’s happening:

I am having trouble implementing the arrow function to process the data.

This is the example code.

FBPosts.filter((post) => post.thumbnail !== null && post.shares ? 100 && post.likes > 500);

What is the post referring to in the code?
I do not think it is FBposts. But cannot discern how to apply this code to the problem the user is given to solve.

Any help would be appreciated!

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(num) => 
  // change code above this line
  return squaredIntegers;
// test your code
const squaredIntegers = squareList(realNumberArray);

Your browser information:

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

post is each element in the FBPosts array.

But as it is fictional it is a bit hard to say what exactly it might look like. But FBPosts might be an array of objects (more likely JSON comming from an API).

const FBPosts = [
    thumbnail: 'Image link 1',
    shares: 10,
    likes: 5
    thumbnail: null,
    shares: 1000,
    likes: 500
    thumbnail: 'Image link 1',
    shares: 101,
    likes: 501

const res = FBPosts.filter((post) => post.thumbnail !== null && post.shares > 100 && post.likes > 500)
console.log(res[0]); // {thumbnail: "Image link 1", shares: 101, likes: 501}

Great! That is how I was imagining it!
So given that the array in the problem is not not JSON, how do I write an arrow function that accesses the array? I have gone through the array tutorials, but I do not see how accessing an array would apply to this situation.


  1. You have an array of numbers.

  2. You need to “filter” out non positive integers.

  3. You then need to “map” over the positive integers and square them.

Check out the newer version of this challenge on the beta version of FCC. See if it explains things a bit better and maybe the code setup makes it more clear (you still need to complete the challenge on the “stable” version).

Have a look at the methods isInteger and Math.pow to get some idea of how to handle the requirements of “positive integers” and “compute the square”.

Spoiler’ish below, don’t look unless you still need more help.

const squareList = arr => {
  'use strict';
  const squaredIntegers = arr
    .filter(num => make filter only return positive integers)
    .map(num => compute the square);
  return squaredIntegers;
1 Like