I am making a super simple shopping cart application in JavaScript. But I'm stuck in one place that When I run a loop of objects, I want to get the array of the specific product out of all the arrays of objects when I am clicking. Can someone tell me how to get that button array and match it with the array
<ul id="laundry-value"></ul>
<ul id="new-laundry-value"></ul>
<script>
var laundryValue = [
{id: 1, name: 'Sunglasses', price: 25},
{id: 2, name: 'Jeans', price: 10},
{id: 3, name: 'Shirts', price: 15},
{id: 4, name: 'Cables', price: 20}
]
var newLaundryValue = [];
for (var i in laundryValue) {
document.getElementById('laundry-value').innerHTML += '<li>' + '<div class="laundry-name">' + laundryValue[i].name + '</div>' + '<div class="laundry-price">' + laundryValue[i].price + '</div>' + '<button class="laundry-btn" onclick="getLaundryClick()">' + 'Add' + '</button>' + '</li>';
}
function getLaundryClick() {
for (var obj = 0; obj < laundryValue.length; obj++) {
var newValue = laundryValue[obj].id =;
}
console.log(newValue)
}
</script>