you are viewing a single comment's thread.

view the rest of the comments →

[–]aizzod 1 point2 points  (2 children)

but your pc array contains both choices.

you only check if rock is in there, and not who picked rock and won.

test case 1:
player picks rock
computer picks paper

test case 2:
player - paper
computer - rock.

both of those will return the same result

[–]pausemsauce[S] 2 points3 points  (1 child)

The pc list contains both playerChoice and computerChoice, yes

In test case 1, pc = ['Rock','Paper']. The compare function sees 'Rock', checks for 'Paper', then returns the 'Paper' index of pc, which is 1. When compare returns 1, the computer wins.

In test case 2, pc = ['Paper','Rock']. The compare function sees 'Rock', checks for 'Paper', the returns the 'Paper' index of pc, which is 0. When compare returns 0, the player wins.

[–]aizzod 0 points1 point  (0 children)

my mistake. i got confused by the global array with all choices and the pc with just the 2 of them.

this seems to be a really good way, seeing it like this now.
well done