好的,所以我注意到stackoverflow上有很多人遇到这个错误,但是大多数人都涉及到一些我尚未学到的jQuery内容。无论如何,我不知道我在这里可能做错了什么,但这里是代码: var playerAnswer;
var computer;
function getCompAnswer(){
var x = Math.random();
if(x >= 0 && x =< 0.333333333){computer = "Rock";}
if(x > 0.333333333 && x =< 0.666666666){computer = "Paper";}
if(x > 0.666666666 && x =< 1){computer = "Scissors";}
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<title>Rock. Paper, Scissors</title>
<link rel="stylesheet" href="style.css" />
</head>
<body><form id="form-id">
<div id="test"></div>
<script src="script.js"></script>
</head><div class="formstyle">
Choose one: <br>
<input type="radio" id="rock" name="game" onClick="retrievePlayerData();">
Rock
<input type="radio" id="paper" name="game" onClick="retrievePlayerData();">
Paper
<input type="radio" id="scissors" name="game" onClick="retrievePlayerData();">
Scissors
</div>
</form>
<div id="play"></div>
<div class="scoreboard">
<table>
<tr>
<th> You
</th>
<th> The Computer
</th>
</tr>
<tr>
<td id="playScore">
</td>
<td id="compScore">
</td>
</tr>
</table>
</div>
<div id="gamemsg"></div>
</body>
</html>
请注意,大部分内容尚未完成,但我不得不重新启动,而且我被困在这里。 (错误在JavaScript的第5行)。