I'm trying to make simple animation text in React and JavaScript and my problem is that after mapping array with letters result in HTML what I get is <span>[Object object]</span>.
Someone can explain what I do wrong.
animation = () => {
let text = document.querySelector(".hi");
let leterArr = [...text.textContent];
text.textContent = "";
leterArr.map(char => {
return (text.innerHTML += "<span>" +{char} +"</span>")
})
}
leterArr.forEach(char => text.innerHTML += `<span>${char} </span>`){ char }creates an object literal using shorthand property names. Just remove the{}text.innerHTML = leterArr.map(char => `<span>${char}</span>`).join("")