I'm using ternary expression for player change, and it works fine. ESLint gives me this error - https://eslint.org/docs/rules/no-unused-expressions
activePlayer === 0 ? (activePlayer = 1) : (activePlayer = 0);
Could you help me make my code better?
activePlayer = activePlayer === 0 ? 1 : 0
? Or justactivePlayer = !activePlayer
, and stop messing around with numbers. – jonrsharpeif
conditional, which is kind of confusing. Also, it feels as ifactivePlayer
should actually be a boolean variable rather than an integer (unless it's a multiplayer game and it actually represents a player number). – Álvaro González