Advertisement
dronkowitz

food.js

Jan 20th, 2023
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const recipes = [
  2.   {
  3.     name: "Pizza",
  4.     ingredients:["dough", "tomato sauce", "cheese", "toppings"
  5.     },
  6.   {
  7.     name: "Tacos",
  8.     ingredients: ["tortillas", "ground beef", "cheese", "lettuce", "salsa"]
  9.   }
  10.   ];
  11. const recipesList = document.getElementById("recipe-list");
  12.  
  13. for let i = 0; i < recipes.length; i++) {
  14.   let recipe = recipes[i]
  15.   let recipeEl = document.createElement("div");
  16.   recipeEl.innerHTML = `<h2>${recipe.name}</h2><ul>`;
  17.   for let j = 0; j < recipe.ingredients.length; j++) {
  18.     let ingredient = recipe.ingredients[j];
  19.     recipeEl.innerHTML += `<li>${ingredient}</li>`;
  20.   }
  21.   recipeEl.innerHTML += `</ul>`;
  22.   recipesList.appendChild(recipeEl);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement