Write Higher Order Arrow Functions - Code incomplete

Write Higher Order Arrow Functions - Code incomplete
0.0 0

#1

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);
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/67.0.3396.99 Safari/537.36.

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


#2

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


#3

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


#4

@hbar1st ahhh, how do I eliminatre fractions though?


#5

@alhazen1 ahhh, how do I eliminatre fractions though?


#6

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


#7

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));


#8

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!