Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Aldhanekaa/2b87d3180d2c0263235cab59a020b625 to your computer and use it in GitHub Desktop.
Save Aldhanekaa/2b87d3180d2c0263235cab59a020b625 to your computer and use it in GitHub Desktop.
FCC course challenge
const squareList = (arr) => {
// Only change code below this line
if (Array.isArray(arr)) { // check if the arr is an arrat
console.log('hello world')
arr = arr.filter(element => typeof parseInt(element) == 'number')
.filter(element => element > 0 && element.toString().indexOf('.') == -1)
.map(element => element ** 2);
console.log(arr)
return arr;
}else
return 'OOPS arr is not an Array!'
// Only change code above this line
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment