Whenever this code runs, an interesting type error occurs within the if statement. It says: Cannot read property product.thumbgallery1 of undefined.
var urlArray= [];
var product = '<%- product %>';
console.dir(product);
for (var count = 1; count < 6; count++) {
var stringCount = count.toString();
if ( typeof product.data["product.thumbgallery" + stringCount].value.main.url === 'undefined' ) {
null
} else {
urlArray.push( product.data['product.thumbgallery' + stringCount].value.main.url )
}
}
Interestingly enough, this snippet of code actually gets the job done:
var lol = '<%- product.data["product.thumbgallery1"].value.main.url %>';
console.log(lol);
What's happening behind the scenes here?