Simple Rock, Paper, Scissors

Hey friends, decided to make a quick game during some of the downtime at work over a couple days. Would love some feedback, especially on how I can maybe refactor the Javascript a bit better.

PS: If you happen to have an iPhone and are able to, I’d like to know how it shows up there. Had a friend say she had an issue on hers using safari and chrome.



You could simplify your playerChoice function like:

function playerChoice() {
  const playerChoices = document.getElementById('playerChoices');
  playerChoices.addEventListener("click", function(event) {
    p1 =;   
    player.innerHTML = `<i class='fas fa-hand-${p1}'></i>`;
    setTimeout(function() {
    }, 2000);

Something similar could simplify your aiChoice function also.

The game function could be simplified by using a lookup table for p1 winning combos.

1 Like

Thanks so much for your response. I’ll take a look at the code. I had tried adjusting the scope of some of the variables to local and it was causing issues, but I’ll check this out. Also, didn’t know about look up tables, so excited to learn about that.

Thanks again.

1 Like

Hey Modu, beautiful project! The animation of Rock … Paper … Scissors … Shoot is fun. The Font Awesome hand icons is a cute touch too

I did end up breaking it though… when clicking a selection multiple times, the script runs multiple times, resulting in multiple played games at the same time. Restrict the user from clicking on an option again while the game is being played

Wow, I think it’s amazing!!!

Ha! Great catch, I didn’t even think of that. I’ll get to work on it!

Thanks so much, you’re very kind!

1 Like