Alright, new to coding here, but in my JavaScript program I am attempting to add 2 new conditions to the already popular RPS game (Lizard and Spock). However, when adding these two new conditions in the index.js
file, nothing seems to happen.
I've tried changing up the math to .20
each but that did not seem to do anything. I believe that the problem is that I am using the wrong function for 5 different variables (if, else if)
function run() {
playerChoice = this.innerText;
computerGamble();
compare();
}
function computerGamble() {
var dice = Math.random();
if (dice <= 0.33) {
computerChoice = "Rock";
} else if (dice > 0.33 && dice <= 0.66) {
computerChoice = "Paper";
} else {
computerChoice = "Scissors";
} else {
computerChoice = "Lizard";
} else {
computerChoice = "Spock";
}
}
All variables/conditions should have an equal chance to be picked.