diff --git a/script.js b/script.js index 80f5aa8..4ef2cf5 100644 --- a/script.js +++ b/script.js @@ -1,58 +1,35 @@ const products = [ -{ id: 1, name: "Laptop Pro 15", price: 1499 }, -{ id: 2, name: "Kabellose Maus X2", price: 49 }, -{ id: 3, name: "Gaming Tastatur RGB", price: 89 }, -{ id: 4, name: "4K Monitor UltraSharp", price: 399 }, -{ id: 5, name: "USB-C Dockingstation", price: 129 } + { name: "Laptop Pro 15", price: 1499 }, + { name: "Kabellose Maus X2", price: 49 }, + { name: "Gaming Tastatur RGB", price: 89 }, + { name: "4K Monitor UltraSharp", price: 399 }, + { name: "USB-C Dockingstation", price: 129 } ]; +const list = document.getElementById("productList"); +const text = document.getElementById("textFilter"); +const price = document.getElementById("priceFilter"); -const productList = document.getElementById("productList"); -const textFilter = document.getElementById("textFilter"); -const priceFilter = document.getElementById("priceFilter"); +function showProducts() { + const t = text.value.toLowerCase(); + const p = Number(price.value); + list.innerHTML = ""; -function formatPrice(p) { -return p.toLocaleString('de-DE') + ' €'; + products + .filter(item => + item.name.toLowerCase().includes(t) && + (!p || item.price <= p) + ) + .forEach(item => { + list.innerHTML += `