This is my first JavaScript project and I am having some difficulties to append the <span> tag separately to each value of an array. Whatever I tried so far results in a single <span> tag. What could be an elegant solution using native JavaScript? Thanks in advance for any help.
let numbers = [1990, 1991, 1992];
let history = [];
let historyContainer = document.getElementById("output");
let para = document.createElement("p");
history.push(numbers.join(" "));
for (let k in history) {
let text = document.createElement("span");
let node = document.createTextNode(history[k]);
text.appendChild(node)
para.appendChild(text);
historyContainer.appendChild(para);
}
<div id="output">
</div>
