At long last 😀#60
Conversation
| dealCards = () => { | ||
| if (this.state.cardDeck.length < 2) { | ||
| // Check if there are enough cards in the deck | ||
| return; |
There was a problem hiding this comment.
I think this check is good, but you are not handling it however. A simple return would leave the user with a blank screen. Maybe do something else, like making a new deck, rendering some text inform the user about what happens etc.
| winner: null, // Resets the winner when dealing new cards | ||
| }); | ||
|
|
||
| console.log(this.newCurrCards); |
There was a problem hiding this comment.
Always remove console.logs before pushing code
| this.setState((prevState) => ({ | ||
| player1Score: prevState.player1Score + 1, |
There was a problem hiding this comment.
I think you could just add the winner state update into the respective player's updates.
| this.setState((prevState) => ({ | |
| player1Score: prevState.player1Score + 1, | |
| this.setState((prevState) => ({ | |
| player1Score: prevState.player1Score + 1, | |
| winner: this.player1 |
| ///////////// | ||
| // Extract cards and determine winner | ||
| // extracts the two cards and saves the 2 objects into the class properties, player1 and player2 | ||
| [this.player1, this.player2] = this.newCurrCards; |
There was a problem hiding this comment.
Does this work? All I see this that you define the variables as this.player1. It is not exactly a this.player1 = this.newCurrCards[0].
Why do you not store the players in state by the way? Especially since these values get updated and need to be persistent values?
| The overall winner is:{" "} | ||
| {this.state.player1Score > this.state.player2Score | ||
| ? "Player 1" | ||
| : "Player 2"} |
There was a problem hiding this comment.
So for a tie, Player 2 would be the overall winner?
| @@ -0,0 +1,171 @@ | |||
| import React from "react"; | |||
There was a problem hiding this comment.
I am a bit confused. What is the difference between App.js and AppOriginal.js? I only just noticed those are 2 different files, which makes my review a bit unreliable. Please only keep 1 copy of a component in your repositories, as this would confuse anyone reviewing or reading your code
No description provided.