If I have four div’s with id 1,2,3,4 and I want this function to write “good morning” in each div.
My code below does not work.
Does anyone know?
function beCheerful(x) {
let line = "";
var box = document.getElementById(x);
line +=('good morning ');
box.innerHTML = line;
}
for(x = 1; x <=4; x++){
beCheerful(x);
}