Simple Basketball Game with JavaScript: Shoot and Score!
<!DOCTYPE html>
<html>
<head>
<title>Basketball Game</title>
<script type="text/javascript">
function shoot(){
var score = Math.random();
if(score < 0.5){
alert('You missed!');
}
else {
alert('You made it!');
}
}
</script>
</head>
<body>
<h1>Basketball Game</h1>
<button onclick="shoot();">Shoot</button>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lnPO 著作权归作者所有。请勿转载和采集!