reverse ?

master
km0 3 years ago
parent f1d9539a29
commit f33a9f9f99

@ -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);

Loading…
Cancel
Save