Does anybody know why this code does not create as many elements as I enter in the
repeat variable?
It creates only 1 element and not 5, why?
function create(el, w, h, bg, repeat){
for(let i=0; i<repeat; i++){
el = document.createElement(el);
el.style.width = w;
el.style.height = h;
el.style.background = bg;
document.body.appendChild(el);
}
}
create("div","100px", "100px", "black", 5);
eltwice with two different meanings. The second iteration of the loop doesn't like it.