function game(userChoice){
const computerChoice = getComputerChoice();
switch (userChoice + computerChoice) {
case 'rs':
case 'pr':
case 'sp':
win(userChoice, computerChoice);
break;
case 'rp':
case 'ps':
case 'sr':
lose(userChoice, computerChoice);
break;
case 'rr':
case 'pp':
case 'ss':
draw(userChoice, computerChoice);
break;
}
}
I’ve look at your code and I’ve noticed that you call the function (let’s take win for example) like this:
win(userChoice + computerChoice); I don’t think you can pass the arguments like that you’d need to use a comma. You also do the same thing with your switch.
I thought the same at first and I was going to point that out. But you can’t use any operators in switch. You can assign those values to a variable and then instead pass in that variable to the switch.
Of course. Through time you’ll get better at debugging your code and deciding when to take a refresher. Before the syntax, I recommend you always check the logic of your code first. Syntax errors will be easier to fix then. Or not depends on how the actual problem reveals itself. Hopefully a not too hard problem.