I keep getting this error when i am trying to connect my string using the + sign. Although, when I use the comma, it only logs "watermelon" the last word in the string. It works when i use the + sign, but I wanna get rid of the error. Whats happening here?
const fruits = ["apple<br>" + "banana<br>" + "grape<br>" + "pear<br>" + "watermelon"];
let output = '';
//code goes here
function listFruits() {
for (let i = 0; i < fruits.length; i++) {
output = fruits[i];
}
}
/*
let output = `
apple: 2 <br>
banana: 3 <br>
grape: 2 <br>
pear: 2 <br>
watermelon: 4 <br>
`;
*/
listFruits();
document.getElementById("app").innerHTML = output;
')` for what you wish to accomplish. Data should be stored without layout. – Lain Aug 05 '20 at 06:12
');`. Yet be aware to avoid `innerHTML` if possible. – Lain Aug 05 '20 at 06:16