Original:
let x = [12,2,3.5,4,-29];
let squared = x.filter((a) => a>0 && Number.isInteger(a)).map((a) => a**2);
Now, think about what we want to do here in order to use the reduce method.
We want take an array and return a new array composed of the squares of all positive integers in our original array.
This means our accumulator in reduce should be an array, since we're returning an array at the end. It also means that we need to include the logical control flow to only add elements to our accumulator that are positive integers.
See below for an example:
const x = [12,2,3.5,4,-29];
const squared = x.reduce((acc, val) => val > 0 && val % 1 === 0 ? acc.concat(val ** 2) : acc, []);
console.log(squared);
// [144, 4, 16]