I set up an empty array, then I'm doing a "for loop" where I set up an empty object, add things to the empty object and finally push the object onto an array.
Technically the array in the beginning should be empty but when I console log it, it still has objects in it. How is that?
function displayIngredients(cocktail) {
// console.log(cocktail);
let ingredients = [];
console.log(ingredients);
let i;
for (i = 1; i < 16; i++) {
const ingredientsMeasure = {};
if (cocktail[`strIngredient${i}`] !== '') {
ingredientsMeasure.ingredient = cocktail[`strIngredient${i}`];
ingredientsMeasure.measurement = cocktail[`strMeasure${i}`];
ingredients.push(ingredientsMeasure);
}
}
console.log(ingredients);
}