function solution(n) { const sqrt = Math.sqrt(n); if (Number.isInteger(sqrt)) { return Math.pow(sqrt + 1, 2); } else { return -1; } }
math.sqrt을 이용하여 n의 제곱근을 구하였고 제곱근이 정수라면 math.pow를 이용해서 제곱근+1의 제곱을 반환하였습니다.