How can I be able to separate my array values with line breaks rather than commas?
It looks like this now: apples,bananas,carrots
I want it to look like this:
apples
bananas
carrots
This is my code:
function insertItem () {
groceryList.push (foodInput.value);
groceryList.toString();
for (var i = 0; i < groceryList.length; i++) {
document.getElementById("printedList").innerHTML = groceryList;
}
foodInput.value = "";
}
function deleteItem () {
groceryList.splice(1,0);
document.getElementById("printedList").innerHTML = groceryList;
}
.joinon your array:groceryList.join("\n");(or possiblygroceryList.join('<br/>');).<ul>?