While creating this short script I came across this error Uncaught TypeError: Cannot read properties of undefined (reading 'brand'). Below is the code that I wrote. Its says error is on the line <p class="brand">${bikes[i].brand}</p>
const bikes = [
{
brand: "Specialized",
name: `Specialized STUMPJUMPER EVO - 29" Carbon Mountainbike - cast battleship`,
price: "5.461,34 €",
image: "../img/mtb/Stumpjumper.jpg",
},
];
for (let i = 0; i <= bikes.length; i++) {
let bikeElement = `
<div class="card">
<p class="brand">${bikes[i].brand}</p>
</div>`;
createBikes();
function createBikes() {
document
.getElementById("container")
.insertAdjacentHTML("beforeend", bikeElement);
}
}