My code seems to be causing an infinite loop and I can’t figure out why. Here it is:
const input = document.querySelector('input');
const btn = document.querySelector('button');
const para = document.querySelector('p');
btn.addEventListener('click', () => {
para.textContent = 'Output: ';
const num = input.value;
input.value = '';
input.focus();
let i = 1;
do {
let sqRoot = Math.sqrt(i);
if(Math.floor(sqRoot) !== sqRoot) {
continue;
}
para.textContent += `${i} `;
i++;
} while(i <= num);
});
Why would this code cause an infinite loop?