Answers for "square root numbers in array javascript"

0

square root numbers in array javascript

function squareOrSquareRoot(array) {
  return array.map(x => {
    const r = Math.sqrt(x);
    return (r % 1 == 0) ? r : (x*x);
  });  
}
Posted by: Guest on April-24-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language