Write Higher Order Arrow Functions - Code incomplete

Tell us what’s happening:
Why does this not work? Thank you in advance

Your code so far

const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
  "use strict";
  // change code below this line
  arr.filter((posint) => posint % 1 === 0 && posint > 0) 
  arr.map((posint) => Math.pow(posint, 2));
  let squaredIntegers = arr;
  // 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/67.0.3396.99 Safari/537.36.

Link to the challenge:

your code is filtering out everything except positive even numbers.
You want to keep odd numbers too…

1 Like

I believe your filter is testing for even integers, not integers

1 Like

@hbar1st ahhh, how do I eliminatre fractions though?

@alhazen1 ahhh, how do I eliminatre fractions though?

posint % 1 === 0 does not pass the test

My problem was that filter doesn’t RETURN an altered/mutated array.

You’ll only need this 1 line of code between the boundaries put up by FCC:
let squaredIntegers = arr.filter((posint) => posint % 1 === 0 && posint > 0).map((posint) => Math.pow(posint, 2));

Filter and map to not mutate the original array, but they will return a new altered array. This preserves the original array and allows you to chain the methods

So you discovered exactly what you were supposed to learn from this lesson. Good job!

1 Like