My randomItem()
function is returning veggies
as undefined. Any idea why?
data = {
bread: ["white", "italian 5 grain", "whole wheat"],
cheese: ["cheddar", "muenster", "provolone", "swiss", "white american", "yellow america"],
meat: ["oven roasted turkey", "oven roasted beef", "maple glazed ham", "black forest ham", "buffalo chicken breast", "bologna", "corned beef", "salsalito turkey", ],
veggies: ["banana peppers", "black olives", "garlic pickles", "cucumbers", "dill pickles", "green peppers", "jalapeno peppers", "lettuce", "onions", "spinach", "tomato", "salt", "black pepper", "oregano", "oil and vinegar"],
condiments: ["honey mustard", "spicy mustard", "mayo"],
extras: ["avocado", "hummus", "guacamole", "bacon"],
bake: ["pressed", "toasted"]
}
const getRandom = (min, max) => {
return Math.floor((Math.random() * (max - min) + 1) + min);
}
function randomItem(item) {
const random = getRandom(0, item.length - 1);
console.log(data.item[random]);
}
randomItem(veggies);
EDIT: My code actually returned 'Reference Error, veggies is not defined'