Currently, I am attempting to loop through an EJS JSON object and verify the existence of values. If a value does exist, I want to add the corresponding URL to an array further down.
Upon loading the page, I am encountering an issue where I am informed that 'count' is undefined. How can I address this problem and resolve it?
var urlArray = [];
var product = '<%= product %>';
console.log(product);
var index;
for (index = 1; index < 6 index++) {
if (product.data["product.thumbgallery" + index] === undefined) {
urlArray.push( <%- product.data['product.imageGallery' + index].value.main.url %>)
}
}
Edit: The issue with 'count' has been rectified. I changed the variable name after coming across the error;