Hi, Im working on a project for my computer science class. im supposed to make a game which will keep track of the scores. however i cannot figure out what i did wrong that the score wouldnt work properly. can you please take a look at my code and see if you can catch the mistakes?
Thanks
<!DOCTYPE html>
<html>
<head>
<title>Rock Paper Scissors</title>
<link rel="stylesheet" type="text/css" href="proj4.css" />
<script type="text/javascript">
var wins=0;
var losses=0;
var ties=0;
var picForLeftPlayer="leftPaperHand.jpg";
var picForRightPlayer="rightRockHand.jpg";
function PlayGame(picForLeftPlayer){
if (picForLeftPlayer=="rock"){
document.getElementById("lefthand").src="leftRockHand.jpg";
}
if (picForLeftPlayer=="paper"){
document.getElementById("lefthand").src="leftPaperHand.jpg";
}
if (picForLeftPlayer=="scissors"){
document.getElementById("lefthand").src="leftScissorHand.jpg";
}
var picForRightPlayer=Math.random();
if (picForRightPlayer<=0.3333){
document.getElementById("righthand").src="rightRockHand.jpg";
}
else if (picForRightPlayer<=0.6666){
document.getElementById("righthand").src="rightPaperHand.jpg";
}
else{
document.getElementById("righthand").src="rightScissorHand.jpg";
}
if (picForLeftPlayer=="rock" && picForRightPlayer=="rock"){
ties=ties+1;
document.getElementById("Ties").innerHTML = ties;
}
if (picForLeftPlayer=="rock" && picForRightPlayer=="paper"){
losses=losses+1;
document.getElementById("Losses").innerHTML=losses;
}
if (picForLeftPlayer=="rock" && picForRightPlayer=="scissors"){
wins=wins+1;
document.getElementById("Wins").innerHTML=wins;
}
if (picForLeftPlayer=="paper" && picForRightPlayer=="paper"){
ties=ties+1;
document.getElementById("Ties").innerHTML=ties;
}
if (picForLeftPlayer=="paper" && picForRightPlayer=="rock"){
wins=wins+1;
document.getElementById("Wins").innerHTML=wins;
}
if (picForLeftPlayer=="paper" && picForRightPlayer=="scissors") {
losses=losses+1;
document.getElementById("Losses").innerHTML=losses;
}
if (picForLeftPlayer=="scissors" && picForRightPlayer=="rock"){
losses=losses+1;
document.getElementById("Losses").innerHTML=losses;
}
if (picForLeftPlayer=="scissors" && picForRightPlayer=="paper"){
wins=wins+1;
document.getElementById("Wins").innerHTML=wins;
}
if (picForLeftPlayer=="scissors" && picForRightPlayer=="scissors"){
ties=ties+1;
document.getElementById("Ties").innerHTML=ties;
}
}
Bookmarks