how can we give the index of an array as an ID to an element code example
Example: how can we give the index of an array as an ID to an element
//Here the delete button gets a unique ID everytime, the ID is the array index of the element.
array.forEach(function (element, index) {
display =
display +
`<tr>
<th scope="row">${index + 1}</th>
<td>${element.first}</td>
<td>${element.second}</td>
<td>${element.third}</td>
<td><button type="button" id="${index}" onclick="deleteNode(this.id)" class="btn btn-danger">Delete</button></td>
</tr>`;
});