I need to assign specific attributes to each player in a game. Each player should have different sets of holes, with each hole having its own win, lose, push, and points values ranging from 0-20.
Is there a simple way to accomplish this task?
As a beginner in javascript, I would greatly appreciate any feedback on the code below :D
let players = document.querySelectorAll('#players div');
let holes = document.getElementById('holes');
let arrPlayers = [];
let arrHoles = [];
for (let a = 0; a < holes.length; a++) {
arrHoles.push({
win: false,
lose: false,
push: false,
points: "2"
});
}
console.log(arrHoles);
players.forEach(function(index, value) {
//Assigning attributes to each player
arrPlayers.push({
/*I WANT THIS TO BE ASSIGNED FOR EACH HOLE*/
/*holes: [{
win: false,
lose: false,
push: false,
points: "2"
}],*/
name: players[value].childNodes[0].data,
id: players[value].getAttribute("data-id")
});
//arrPlayers[value];
//arrPlayers.push(arrHoles);
});