Last active
July 9, 2020 17:30
-
-
Save CodeNextAdmin/62ee629fb0f69d622cce7901593ec26e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const READLINE = require("readline-sync"); | |
const options = ["rock", "paper", "scissors"]; | |
console.log(`Let's play Rock Paper Scissors!`); | |
// Challenge | |
// Find the bugs below: | |
while(true){ | |
let userInput = READLINE.question(`Do you want to play rock, paper, or scissors? `).toLowerCase(); | |
randomSelection = Math.floor(Math.random()*3); | |
computerSelection = options[randomSelection]; | |
console.log("You played: ${userInput} and the computer played: ${computerSelection}"); | |
if(userInput === computerSelection){ | |
console.log("It's a tie!"); | |
} | |
else if((userInput = "rock" && computerSelection = "paper") || | |
(userInput = "paper" && computerSelection = "scissors") || | |
(userInput = "scissors" && computerSelection = "rock")){ | |
console.log("You Lose!"); | |
} | |
else if{ | |
console.log("You Win!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment