I have 3 buttons in my HTML file with the same onclick
function name
<button id="name 1" onclick="choice()">John</button>
<button id="name 2" onclick="choice()">Martin</button>
<button id="name 3" onclick="choice()">Sam</button>
and a JS file that makes a list out of the buttons names and each name has a point
property set to 0
let characters = [
{name: document.getElementById("name 1").textContent, points: 0},
{name: document.getElementById("name 2").textContent, points: 0},
{name: document.getElementById("name 3").textContent, points: 0}
];
is there a way I can make a function unique even with a mutual name so that when i click on that button, it runs a function related to that button only (for my case clicking on John adds a point to him only and no one else). Also, how do i change the number of the points
property so that every time i click on a button it adds 1 point