I'm trying to create a function that uses the number input I got from users to create the same amount of division inside of a container division.However, no matter what the number is, it always creates only 1 div. It seems like the for loop inside my function is being avoided.
I've tried to alter the function, checked number input whether it is defined or undefined.
function createGrid(parameter) {
for (i = 0; i < parameter * parameter; i++); {
const div = document.createElement('div');
newDiv = container.appendChild(div);
newDiv.setAttribute('class', 'newDiv');
}
return newDiv;
}
container?;afterforloop.const divis a new div you create. In the next line, you (re-)declare a global variablenewDivand set it to becontainer. Where iscontainerdefined? Then you apply thenewDivclass to the container over and over again.