When a user enters a word in a text input, it is displayed on my page. And so the names can accumulate. At the same time, I want the names to be pushed into an array. Unfortunately, I can't do it:
function getinnerText() {
const arr = []
const newProduct = document.createElement("li");
newProduct.textContent = `${name}`;
document.querySelector(".nameArea").appendChild(newProduct)
arr.push(name)
}
It always creates me my array with only the last value added.
Does anyone have a solution? Thanks a lot =)!
function getinnerText(name) { const arr = [] const newProduct = document.createElement("li"); newProduct.textContent =${name}; document.querySelector(".nameArea").appendChild(newProduct) arr.push(name) }