I am working on a side-project to improve my FE-development skills and am designing a (fictional) toilet paper shop.
As a first step, I hard-coded some mock products directly into my HTML file (including brand name, product name and price). However, as a next step I want to put the product information in arrays instead and have my web page display the product info dynamically. Here is my array structure:
let products = [
{
id: 0,
name: "Normal Tee",
imageSrc: "",
formattedPrice: "15 €",
price: "15.00",
brand: "Tee Pee Originals",
category: "['classic', '2x layers']"
},
{
id: 1,
name: "Rainbow Tee",
imageSrc: "",
formattedPrice: "20 €",
price: "20.00",
brand: "WC Unlimited",
category: "['colorful', '2x layers']"
},
{
id: 2,
name: "Eco Tee",
imageSrc: "",
formattedPrice: "25 €",
price: "25.00",
brand: "Tee Pee Originals",
category: "['eco-friendly', '2x layers']"
},
{
id: 3,
name: "Deluxe Tee",
imageSrc: "",
formattedPrice: "30 €",
price: "30.00",
brand: "Tee Pee Originals",
category: "['deluxe', '5x layers']"
},
{
id: 4,
name: "Comfy Tee",
imageSrc: "",
formattedPrice: "22 €",
price: "22.00",
brand: "The Comfy Paper",
category: "['3x layers']"
},
{
id: 5,
name: "Super Comfy Tee",
imageSrc: "",
formattedPrice: "27 €",
price: "27.00",
brand: "The Comfy Paper",
category: "['4x layers']"
},
{
id: 6,
name: "Save The World Tee",
imageSrc: "",
formattedPrice: "35 €",
price: "35.00",
brand: "Toilets of the Future",
category: "['3x layers', 'eco-friendly']"
}
];
As you can see, what I am still missing is the image for each product. I have the files for the images in my project folder, but the autocomplete of my IDE (IntelliJ) isn't suggesting anything when I start typing a file path e.g. "./images/..." . Is the syntax for using file paths within the arrays the same as in the src attribute in an HTML file?
For example, if the image for my first product was located in my images folder, do I also just use "./images/(insert file name)" in the data point "imageSrc" in the array?