1.猜数字游戏
三次机会,猜1~50之间的一个整数
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script>
function getRandom(min,max){
return Math.floor(Math.random()*(max-min+1))+min;
}
var random=getRandom(1,50);
var i=0;
while( i<3){
var num=prompt('你来猜数字,输入1~50之间的数字');
if (num>random){
alert('你猜的数字偏大')
}
else if (num < random) {
alert('你猜的数字偏小')}
else if (num ==random){
alert('你猜对了')}
i++
}
alert('3次机会已使用完毕!')
</script>
</html>
2.统计出现次数最多的字符
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"