From 81c80b2549817fa0a448a27f3a66f66cc992ad5d Mon Sep 17 00:00:00 2001 From: Eliott Collin <eliott.collin0307@gmail.com> Date: Tue, 25 Jan 2022 13:20:25 +0100 Subject: [PATCH] use Destructuring --- src/main.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.js b/src/main.js index 9bc016f..cab4ad9 100644 --- a/src/main.js +++ b/src/main.js @@ -24,15 +24,20 @@ const data = [ -const html = data.filter(pizza => pizza.name.split("").filter(value => value === "i").length === 2).reduce((previous, current) => { +const html = data.filter(({name}) => name.split("").filter(n => n === "i").length === 2).reduce((previous, { + image, + name, + price_large, + price_small +}) => { return previous + `<article class="pizzaThumbnail"> - <a href="${current.image}"> - <img src="${current.image}" alt="${current.name}"/> + <a href="${image}"> + <img src="${image}" alt="${name}"/> <section> - <h4>${current.name}</h4> + <h4>${name}</h4> <ul> - <li>Prix petit format : ${current.price_small} €</li> - <li>Prix grand format : ${current.price_large} €</li> + <li>Prix petit format : ${price_small} €</li> + <li>Prix grand format : ${price_large} €</li> </ul> </section> </a> -- GitLab