<html>
<head>
<meta charset="UTF-8">
<title>출력결과</title>
</head>
<body>
<script>
function isPrime(x) {
// 문자열뒤집기
let str = x.toString();
let sum = 0
for (let i = str.length - 1; i >= 0; i--) {
sum += str[i];
}
let num = parseInt(sum);
for (let j = 2; j < num; j++) {
if (num % j === 0) {
return false;
}
}
if (num !== 1) return num;
}
function solution(arr) {
let answer = [];
for (let x of arr) {
if (isPrime(x)) {
answer.push(isPrime(x));
}
}
return answer;
}
let arr = [32, 55, 62, 20, 250, 370, 200, 30, 100];
console.log(solution(arr));
</script>
</body>
</html>
강의 잘보고 있습니다.