Tac-Toe game and want to include a scoring system. I have created a factory function for players, but I am unable to implement the scoring functionality correctly. When I attempt to call player1.getScore(), it doesn’t seem to reflect the updated score. How can I properly implement and manage scores for each player?
let currentPlayer;
let player1, player2;
let score = 0;
const playerSelection = (name, marker) => {
return {
name,
marker,
};
};
player1 = playerSelection("Name", gameMarker[0]);
player2 = playerSelection("Name", gameMarker[1]);
const getScore = () => score;
const scorePlus = () => ++score;
player1.scorePlus()
console.log(player1)```