I'm relatively new to JavaScript and working on some exercises. I'm trying to create an exercise where customer review display once the page loads one at a time 5 seconds each. The reviews are each an object array element. So I'm trying to figure out how to loop through the object array and display each element 5 seconds each. I've done some research and this is all I could come up with. Am I even close?
<script>
var customerReviews = {
"Denise Wilson": [
"I absolutely love this restaurant! The food is amazing. The atmosphere
is so welcoming."
],
"Russell Brown": [
"Enid's restaurant is the best place in town. Great food, nice staff
and
very clean spot."
],
"Dana Evans": [
"Came here for the 1st time and must say I'm impressed. Will definitely
be coming back. Enjoyed myself."
],
"Bilal Scott": [
"Been coming here since I was a child. Loved it then and still love it
now. The best!"
]
};
function showCustomerReviews(){
for (i = 0; i < userWord.length; i++){
setTimeout(function () { .show(customerReviews[i]); }, 5000);
}
}
</script>
HTML
<body onload="showCustomerReviews()">
<div id="reviewsPage">
<h2>Check out Enid's Restaurant Customer Reviews below</h2>
<div id="reviewsBox">
<p>Enid's Customer Reviews</p>
<p id="displayReviews"></p>
</div>
</div>