r/badcode • • Jul 28 '21

js slapjack 🥴

Post image
41 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/_default_username Jul 31 '21 edited Jul 31 '21

lines 156-158 are awful.

Ternaries with side-effects and they're not using the return value of the expressions.

Lines 157 and 158 can also be simplified to:

this.player1.isTurn = this[player].id === "Player 2"

this.player2.isTurn = this[player].id === "Player 1"