const p1Wins = [];
function raiseScore() {
if(xWinMessage) {
const p1Name = document.querySelector('.p1-name');
p1Name.style.color = 'green';
for(i = 0; i < p1Wins.length; i ) {
p1Wins.push(i)
}
let p1Score = document.querySelector('.p1-score');
p1Score = p1Wins
}
}
Not sure what I'd need to do to make this work. If anyone could help that'd be greatly appreciated.
CodePudding user response:
If you just need to add [1,2,3,etc] in that order. You could do somthing like this.
const p1Wins = [];
const pushStep = () => p1Wins.push(p1Wins.length 1);
// call in the function
pushStep();
pushStep();
pushStep();
console.log(p1Wins);