From f33a9f9f99e43d4e48621bb4e35d21a4123b1360 Mon Sep 17 00:00:00 2001 From: lzzfnc Date: Wed, 20 Oct 2021 20:11:07 +0200 Subject: [PATCH] reverse ? --- cms.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cms.js b/cms.js index 4326416..35fc424 100644 --- a/cms.js +++ b/cms.js @@ -21,17 +21,13 @@ fetch("./cms.json") showSelectedRecipes(); }); - - function populateContents(data) { - data.recipes.forEach((element) => { - if (element.type == 'recipe') { - - addRecipe(element) + data.recipes.reverse().forEach((element) => { + if (element.type == "recipe") { + addRecipe(element); } - if (element.type == 'diary') { - addDiary(element) - + if (element.type == "diary") { + addDiary(element); } }); recipesList = [...document.getElementsByClassName("recipe")]; @@ -66,7 +62,6 @@ function addDiary(diary) { card.appendChild(text); cookbook.appendChild(card); - } function addRecipe(recipe) { @@ -134,7 +129,9 @@ function addRecipe(recipe) { function recipesInfo(recipes) { let ingredients = []; - recipes.filter(recipe => recipe.type == "recipe").forEach((recipe) => (ingredients = [...ingredients, ...recipe.ingredients])); + recipes + .filter((recipe) => recipe.type == "recipe") + .forEach((recipe) => (ingredients = [...ingredients, ...recipe.ingredients])); let unique = [...new Set(ingredients)]; ingredientsList = Array.from(unique);