Challenge: Solution Review
This lesson will explain the solution to the problem from the previous coding challenge.
We'll cover the following...
We'll cover the following...
Solution
Explanation
In the code above, we have a TruthAndDare class, which has a playGame function that decides which player’s turn it is, depending on the turn variable. The constructor initializes turn to either 1 or 2 randomly.
The turn variable is accessed through the Getturn function.
Getturn(){
if(this.turn == 1){
this.turn = 2
}else{
...