I've been looking for an answer to this but the fixes I have found have not helped so figured I would just outright as where im going wrong (like always - any help here is very appreciated)
So I have an array of objects, with reviews and I need it to post a new review on the site each 10 seconds i.e. update the text ect:
I figured I would use:
review = [{
name: 'X',
rating: 'X',
review: 'X'
},
{
name: 'X',
rating: 'X',
review: 'X'
}]
Then update the html of the site using a setTimeout function and for loop (apparently this is not as easy as I had believed) -
function init(){
var name = document.querySelector('.name');
for(i=0; i<reviews.length; i++){
setTimeout(function(){
name.innerHTML = reviews[i].aditional_info_name;
},10000)
}
}
Any input here would really help - I have seen some other posts on this subject but I haven't managed to implement a fixed based on what i have seen thus far.
The issue -
I keep getting:
Thanks in advance, W