Need help on table

Here is the link to codepen

As you can see if i going to have more and more entries, my js code will be very long and they seem to similar to each other. Is there a way to simplify this?

The Price section will be a constant (Different for each food), i cant think of a way to select it beside using ID…

yes there are plenty of choices for you.
The first one that comes to my mind would be to generate your list of products in your javascript file.

This way, you’ll be able to iterate much more easily with a simple “for” loop.

for example

let food = [
		name:'Kong Pow Chicken',
		name: 'steam Chicken',

const foodGeneration = `<div><h1> ${food[0].name} </h1></div>`;
document.getElementById('test').innerHTML = foodGeneration;

‘test’ is the id of the div where I want to generate my html. Put that in a for loop, tweak things a little, and that should do the trick ^^

Sorry this post is a bit messy, but I just woke up and I am writing this in my underwear with a hot cup of coffee to wake me up ^^

Good luck, hope that helps :wink:

thanks For the help :slight_smile: get the things done!