I am trying to recreate a "Today's Special" menu so that every time the page is refreshed, a different type of pizza will populate, but with the correct properties within the arrays. So the 0 indexed data all belong together, and the 1 indexed belong together, etc. Here is my code that I tried, but it populates randomly from any random variable. Please help.
I want it to look like: "Today's Special: pizzaName + price + description"
var pizzaName = ['Four Loop', 'Conditional Love', 'The DOM','Conjunction Function'];
var price = [44.44, 22.14, 16.99, 17.02];
var description = ['Spin your wheel with this quattro cheese mix doused in garlic and truffle oil. Loop there it is!', 'This island favorite doesn\'t give you a chance to say no. Korean bulgogi meat, kim chee, mozzarella cheese and onions always returns true! Boo~Ya!', 'This dynamic blend of Duck, Olives and Mango will change your original thought of what a pizza should be. The only thing constant is change for this bad boy!', 'Create your own pie by passing in handpicked fresh ingredients. Invoke your appetite and creativity! Mamma Mia return back to glory!'];
HTML:
<section id="today">
<div class="content">
<h3 class="sectionTitle">Today's Special</h3>
<p id="special">Conditional Love</p>
</div>
</section>
JavaScript:
function randomPizzaFunction(hungry, hungrier, hungriest){
for(var i = 0; i<hungry.length; i++){
var displayTodaysSpecial = hungry.concat(hungrier).concat(hungriest);
console.log(displayTodaysSpecial[i]);
}
return displayTodaysSpecial;
}
randomPizzaFunction(pizzaName, price, description);
var genRandomPizza = randomPizzaFunction(pizzaName, price, description);
console.log(genRandomPizza);
var changeSpecial = document.getElementById("special");
changeSpecial.innerHTML = genRandomPizza[Math.floor(Math.random() * genRandomPizza.length)];