Still learning the basic shit but yeah figured out how to make a simple RPS game
Go try it on jsfiddle if you want and/or tell me how I can make it better ;_;
https://jsfiddle.net/
var choice = prompt("Do you choose rock, paper, or scissors?");
var compchoice = Math.random();
if (compchoice < .34) {
compchoice = "rock";
}
else if (compchoice <= .67) {
compchoice = "paper";
}
else {
compchoice = "scissors";
}
document.write("Computer: " + compchoice + "<br>");
if (compchoice === choice) {
document.write("It's a tie");
}
else if (choice === "rock") {
if (compchoice === "paper") {
document.write("You have lost");
}
else {
document.write("You have won");
}
}
else if (choice === "paper") {
if (compchoice === "rock") {
document.write("You have won");
}
else {
document.write("You have lost");
}
}
else if (choice === "scissors") {
if (compchoice === "paper") {
document.write("You have won");
}
else {
document.write("You have lost");
}
}