I'm not understand me? Help me please!

Use arrow function syntax to compute the square of only the positive integers (fractions are not integers) in the array realNumberArray and store the new array in the variable squaredIntegers.

const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
“use strict”;
// change code below this line
// change code above this line
return squaredIntegers;
// test your code
const squaredIntegers = squareList(realNumberArray);

You have to write your code here.

// change code below this line
// change code above this line

You can use Array methods like map, filter and reduce to get the desired result.

And the problem is realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34]; contains some fraction values which you need to skip and square only the positive integers.

Positive Integers are : 4, 42, 6.
Fractions/Decimal values are 5.6, -9.8, 3.14, 8.34


  1. Use map and reducer methods
  2. You can use es6 Number.isInteger() or Math.floor

I hope this helps you to solve the problem.

Thank you, but Math.floor can’t help because this method equal fractions but i must used positive 4, 42, 6.
This my code
// change code below this line

const squaredIntegers = arr.filter((arr) => (Math.pow(arr, 2)));
// change code above this line

But i have error because i used all int, but i know how use only positive int

Hey, please search the forum.
Someone already posted a question about this and you can see the follow up messages.
And you can find a viable solutions to solve this challenge.

oke, thank you friend

Here you go

1 Like

hm, i try many way, but all way was not good, but similar. What is acc and num in the reduce?

const squaredIntegers = arr.map(
function doubleNumber( currentValue ) {
return Math.pow(currentValue, 2);
But i got array with undifined value, how clear their?

You have written the map function wrongly, you need a variable to loop through an array and you cannot add doubleNumber inside map directly.

And I don’t think you should use both Number.isInteger and Math.pow together.

Here is the solution using your current code.

const arr = [4, 2.3, 42, 3.9, 2.5, 2];

const squaredIntegers = []; //if you directly add map method here, it will return the skipped values too.

arr.map(currentValue => {
    return squaredIntegers.push(currentValue * currentValue);


Read more here