Nested loop in JavaScript. Help me

let groceryList = [‘orange juice’, ‘bananas’, ‘coffee beans’, ‘brown rice’, ‘pasta’, ‘coconut oil’, ‘plantains’];
let groceryTobuy = [‘orange juice’, ‘kiwi’, ‘bananas’];
let Gotomarket = ;

for (let i = 0; i < groceryList.length; i++); {
for (let j = 0; j < groceryTobuy.length; j++); {
if(groceryList[i]===groceryTobuy[j]) {
Gotomarket.push(groceryList[i]);
}
}
};
what is wrong with the lines? I think I did exactly same as the instruction…

1 Like

There shouldn’t be a “;” at the end of a for loop. This line should look like this:

for (let i = 0; i < groceryList.length; i++) {

(NOTE the absence of the ; before the last bracket {)

1 Like

Thank you so much! Problem solved.

1 Like