diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..9f1695e3 Binary files /dev/null and b/.DS_Store differ diff --git a/public/index.html b/public/index.html index 138da963..15526236 100644 --- a/public/index.html +++ b/public/index.html @@ -5,10 +5,13 @@ My Store - - - + + + +
+ + - \ No newline at end of file + diff --git a/public/index.js b/public/index.js index e69de29b..89c22544 100644 --- a/public/index.js +++ b/public/index.js @@ -0,0 +1,44 @@ + +let data = { + products, + search: document.getElementById('search').value, +}; + +function hideProducts() { + let products = document.getElementById('products'); + products.style = 'display: none;'; +} + +function getProductsList() { + let data = '
'; + products.forEach(p => { + data += `name: ${p.name}
${p.description}
+ rating: ${p.rating}
+
+ price: ${p.price}
+ category: ${p.category}
+ ${getReviews(p.reviews)}`; + }); + data += '
'; + return data; +} + +function getReviews(review) { + let reviews = ''; + review.forEach(r => { + reviews += `
${r.description}
${r.rating}`; + }); + return reviews; +} + +function search() { + console.log(data.search); +} + +function main() { + let showProducts = true; + let x = document.getElementById('hi'); + document.write(getProductsList()); +} + +main()