Make a rock, paper, scissor game

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

```

Use this code. It takes a lot of my time to debug… Check this let me know about any error!

var choices = [“rock”, “paper”, “scissors”];
var choices = [“rock”, “spock”, “paper”, “lizard”, “scissors”];

function mod(a, b) {
c = a % b
return (c < 0) ? c + b : c
}

function compare(choice1, choice2) {
x = choices.indexOf(choice1);
y = choices.indexOf(choice2);
if (x == y) {
return “Tie”;
}
if (mod((x - y), choices.length) < choices.length / 2) {
return choice1 + " wins";
} else {
return choice2 + " wins";
}
}

var result = “”

for (i in choices) {
for (j in choices) {
left = choices[i];
right = choices[j];
result += left + " " + right + " " + compare(left, right) + “\n”;
}
}

console.log(result);

<do not remove the three backticks above>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.