Hey, welcome back.
This lesson we're going to check to see who the winner is of the dice roll.
So creating another method within our constructor object using the method and we're going to create
a brandnew function.
And in this function, we're going to take in a few parameters.
We need role one and rule two.
So we have something, some values that we can use to make the comparison.
So checking to see if role one is greater than role two.
We know that the winner of this is going to be being returned back player wins, assuming that the first
one is the player that's being Pastan.
And then also we'll do another check to see if role two is greater than roll one.
So there can only really be three possibilities return.
And this means that the computer wins.
And again, we're hoping that rule one is for the player.
Role two is for the computer.
And if that changes, then, of course, you do need to change and adjust your messaging.
And if we don't have one winning over the other, then this is just simply a tie.
So we're turned back a tie.
So now we've got a way to check and we're not going to see anything quite different yet.
And that means that we need to check to see who the winner is.
So let's use that game object and the brand new checker method that we just created and taking in the
player role and then also the computer roll.
And remember, it does have to be in that order and I'll log out whatever is being returned from winner.
So let's see what happens.
So role here, player wins role again, computer wins and we should also output those values.
So let's take dice and we're going to update that message so that, again, for those of for those of
us that are sharing the game or don't like to look into the console to see what the values are, let's
output that and say player and we'll get the value of the player role versus and then this is the computer
role.
And that means that whatever the value of winner is, we'll just have put that message.
It's a very simple message here.
And we see player six versus one.
So the computer got a one.
We could also output as well computer.
So let's try that again.
So player five versus computer five.
So that's a tie game.
Player five versus computer three.
So that means the player wins another tie and this time player got a four versus computer five.
So that means the computer wins.
So now we've got a quick little function in game.
Have some fun with it.
Try it out.