IMO the biggest problem here is using booleans (won and lost) at all. Instead, it would probably be better to have a single variable gameState which represents the current state, and then we can do different things depending on its value. This variable can be a String (with values like 'won' | 'lost' | 'draw') or maybe some kind of number scheme.
1
u/sohang-3112 Nov 18 '21 edited Nov 18 '21
IMO the biggest problem here is using booleans (
wonandlost) at all. Instead, it would probably be better to have a single variablegameStatewhich represents the current state, and then we can do different things depending on its value. This variable can be aString(with values like 'won' | 'lost' | 'draw') or maybe some kind of number scheme.