Reputation: 1850
I am trying to append elements with multiple values from my array, but i am doing something wrong. This is my code:
for(var i=0; i < pricesArray.length; i++) {
var ulList = document.getElementById('season-prices');
ulList.append(`
<div class="flex"> <input type="checkbox"></input> <span>` + pricesArray[i].start_date `</span> <span>` + pricesArray[i].end_date `</span>
<span>` + pricesArray[i].currency `</span> <span>` + pricesArray[i].price `</span> </div>
`)
}
The error I get is:
pricesArray[i].start_date is not a function
Is there another way, or a better way to do this? I used to do something like this in jQuery but cannot remember where and how exactly..
Upvotes: 0
Views: 350
Reputation: 402
you are missing '+' after pricesArray[i].start_date. also after every property. you need to put plus symbol in front and back.
for(var i=0; i < pricesArray.length; i++) {
var ulList = document.getElementById('season-prices');
ulList.append(`
<div class="flex"> <input type="checkbox"></input> <span>` + pricesArray[i].start_date + `</span> <span>` + pricesArray[i].end_date + `</span>
<span>` + pricesArray[i].currency +`</span> <span>` + pricesArray[i].price + `</span> </div>
`)
}
Upvotes: 3