Hi, I’m trying to do the 3rd Loop exercise from ‘test your skills’ section but I cannot find a bug in my code. I checked other posts here but it didn’t help to find it.
Thank you in advance.
My code:
let para = document.createElement(‘p’);
let i = 500;
function isPrime(num) {
for(let i = 2; i < num; i++) {
if(num % i === 0) {
return false;
}
}
return true;
}
do{
if(isPrime(i)===true){
para.textContent += i + ", ";
}
else{continue;
}
i--;
}
while(i>1);
let section = document.querySelector('section');
section.appendChild(para);