od0201,
<body>
<script>
const arr1 = [1, 2, 3, 6, 9, 18, 13, 17];
const arr2 = primeNumbers(Math.max(...arr1));
let arr3 = [];
for (let i of arr1) {
if (i in arr2) arr3.push(i)
}
document.write(arr3)
function primeNumbers(n) {
let arr = {};
f: for (let i = 2; i <= n; i++) {
for (let j in arr) {
if (i % j === 0) continue f;
}
arr[i] = true
}
return (arr)
}
</script>
</body>