Skip to content

Instantly share code, notes, and snippets.

View azrikahar's full-sized avatar

Azri Kahar azrikahar

  • MY
  • 02:27 (UTC +08:00)
View GitHub Profile
@azrikahar
azrikahar / rps.js
Last active April 20, 2020 08:22
Sample code for Rock, Paper & Scissors game in response to Reddit thread: https://www.reddit.com/r/learnjavascript/comments/g4jiq8/at_long_last_i_have_finished_my_rock_paper/
// Modified the ordering of these moves so we can do an easier comparison later.
// selectMove sounds more of a verb like a function doing something, so renaming
// to "moves" to signify it is a collection/array of move.
const moves = ["Rock", "Scissors", "Paper"];
let playerScore = 0;
let computerScore = 0;
// Using getComputerSelection() instead of computerPlay()
// lets us know that we will indeed GET something from it,
// ie. the function will return something.