Wednesday, 5 December 2018

Pug Iterating Through Array in JavaScript

I'm trying to iterate through the customers array and display the name of each customer but keep receiving the error "Cannot read property 'Name' of undefined"for (var i = 0; i < #{customers.length}; i++) { alert('#{customers[i].Name}'); } When I try something like alert('#{customers[5].Name}'); it works as expected, so I'm not indexing properly. I also tried alert('#{customers['i'].Name}'); but that didn't work either.​

Submitted December 05, 2018 at 04:56PM by ShortLeek

No comments:

Post a Comment