reverse ?

master
km0 3 years ago
parent f1d9539a29
commit f33a9f9f99

@ -21,17 +21,13 @@ fetch("./cms.json")
showSelectedRecipes(); showSelectedRecipes();
}); });
function populateContents(data) { function populateContents(data) {
data.recipes.forEach((element) => { data.recipes.reverse().forEach((element) => {
if (element.type == 'recipe') { if (element.type == "recipe") {
addRecipe(element);
addRecipe(element)
} }
if (element.type == 'diary') { if (element.type == "diary") {
addDiary(element) addDiary(element);
} }
}); });
recipesList = [...document.getElementsByClassName("recipe")]; recipesList = [...document.getElementsByClassName("recipe")];
@ -66,7 +62,6 @@ function addDiary(diary) {
card.appendChild(text); card.appendChild(text);
cookbook.appendChild(card); cookbook.appendChild(card);
} }
function addRecipe(recipe) { function addRecipe(recipe) {
@ -134,7 +129,9 @@ function addRecipe(recipe) {
function recipesInfo(recipes) { function recipesInfo(recipes) {
let ingredients = []; 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)]; let unique = [...new Set(ingredients)];
ingredientsList = Array.from(unique); ingredientsList = Array.from(unique);

Loading…
Cancel
Save