js选择颜色小游戏(随机生成不含重复数字的数组,通过数组中的数控制定义好的数组)

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>js网页版小游戏</title>
<style media="screen">
.wrap {
577px;
outline: 1px solid hotpink;
margin: 100px auto;
box-shadow: 0 0 5px;
}
.screenDis-wrap{
padding: 22px 0px;
overflow: hidden;
}
#displayCountDown{
display: inline-block;
float: left;
font-size: 3em;
padding: 17px 13px;
color: rgb(255, 100, 100);
}
#displayScore{
display: inline-block;
float: right;
font-size: 3em;
padding: 17px 13px;
color: rgb(255, 33, 33);
}
.textWrap{
padding: 20px 0;
text-align: center;
font-size: 7em;
}
.tip{
padding: 33px 0px;
text-align: center;
font-size: 1.3em;
}
.tip p:nth-child(2){
display: inline-block;
padding: 20px 30px;
background-color: rgb(28, 134, 177);
margin: 20px auto;
font-size: 4em;
cursor: pointer;
}
ul{
text-align: center;
padding: 33px 0px;
}
ul li{
display: inline-block;
77px;
margin: 3px 7px;
text-align: center;
font-size: 3em;
padding:4px 3px;
background-color: darkgreen;
cursor: pointer;
}
</style>
</head>
<body>
<div class="wrap">
<div class="screenDis-wrap">
<div > }

}
return nulArry;
}
//给按钮随机添加内容及随机改变字体颜色函数
var btnsTxtSub=[];
function showTxtColor_buts(){
btnsTxtSub=randomArryNum(5);
for (var i = 0; i < btns.length; i++) {
btns[i].btnSub=i;
btns[i].innerHTML=txtArry[btnsTxtSub[i]];
}
var btnsColorSub=randomArryNum(5);
for (var i = 0; i < btns.length; i++) {
btns[i].style.color=colorArry[btnsColorSub[i]];
}
}
showTxtColor_buts();
//设置点击事件,并匹配点击按钮的文字与oTxt中的文字颜色一致
var uclickable=true;
for (var i = 0; i < btns.length; i++) {
btns[i].onclick=function(){
if (uclickable) {
return;
}
console.log(1);
if (btnsTxtSub[this.btnSub]==oTxt_colorSub) {
++score;
showScore();
}
showTxtColor_buts();
randomShowText_oTxt();
randomShowColor_oTxt();
}
}
//显示得分函数
function showScore(){
displayScore.innerHTML='得分:'+score;
}
//游戏结束函数
function gameOver() {
clearInterval(timer);
if (score<10) {
alert('Come On!');
}else {
alert('Best!')
}
uclickable=true;
}
//倒计时函数,计时结束游戏停止
var timer;
function gameTime(countdown){
if (timer) {
clearInterval(timer);
}
timer=setInterval(function(){
countdown--;
displayCountDown.innerHTML="倒计时:"+countdown
if (countdown==0) {
gameOver();
}

},100)
}
//开始游戏函数
startGame.onclick=function(){
uclickable=false;
gameTime(100);
score=0;
showScore();

}


</script>
</html>