I am ultimately trying to create a function that generates some html based on values in a two dimensional(?) array. However, I am struggling to loop through all of the values. In the following code, it is the bottom else clause that my program never enters:
let food = [
[
'Wedges',
['Hero Wedge', "Lettuce, tomato, yada", '$19.42'],
['Differebt Wedge', "Chicken, tomato, yada", '$12.42'],
],
[
'Chicken',
['Chicken', "Lettuce, tomato, yada", '$19.42'],
['Brocolli Wedge', "Chicken, tomato, yada", '$12.42'],
]
]
generate(food);
function generate(food){
for(i = 0; i < food.length; i++){
for(j = 0; j < food[i].length; j++){
if(j === 0){
sectionName = food[i][j]; // "Wedges"
}
else{
for(y = 0; y < food[i][j]; y++){
console.log("were in this statment"); //Never runs
}
}
}
}
}
When i = 0 and j = 1
doesn't
food[i][j] = ['Hero Wedge', "Lettuce, tomato, yada", '$19.42'] ? And since this is an array with 3 elements y < food[i][j] should evaluate to true? Thanks in advance.
y < food[i][j]->y < food[i][j].length?