• KJ Ha

Voice Rock Paper Scissors

Link to a web app: https://voice-rock-paper-scissors.glitch.me/

Code: https://glitch.com/edit/#!/voice-rock-paper-scissors?path=sketch.js%3A41%3A0



As the title indicates, Voice Rock Paper Scissors is a voice-controlled version of the classic rock paper scissors game.


One of the problems I encountered was that the word "scissors" out of my mouth was recognized as "Ceasars" for more than half of the time. It might be because of my limitations as a non-native speaker, not being able to fully convey a subtle difference in pronunciation between scissors(si·zrz) and Caesars(see·zr).



The simple solution I took was adding Caesars as a value in the dictionary. And used the statement, Object.values(games)[2].includes(phrase) == true), to allow both words "scissors" and "Caesars" to be recognized as scissors in the game.



//Before
let games = {
    "✊": "Rock",
    "✋": "paper",
    "✌": "scissors"
  };
  
//After
let games = {
    "✊": "Rock",
    "✋": "paper",
    "✌": ["scissors", "Caesars"]
  };
  


Demo


© 2020 Kyungjoo Ha. All Rights Reserved