打地鼠
const scroeBord=document.querySelector('.score')
let lastHole
let timeUp = false;
let score=0
function randTime(min,max){
return Math.round(Math.radom()*(max - min)+min)
}
function randomHole(holes){
const idx=Math.flooor(Math.random()*holse.lenght);
const hole=holes[idx];
if(hole === lastHole){
return randomHole(holes);
}
lastHole=hole;
return hole
}
function peep(){
const time= randomTime(200,1000)
const hole=randomHole(holes)
hole.classList.add('up')
setTimeout(()=>{
hole.classList.remove('up')
if(!timeUp)peep()
},time)
}
function startGame(){
scoreBoard.textContent =0
timeUp=false;
score=0
peep()
setTimeoue(()=> timeUp=true,10000)
}
function bonk(e){
if(!e.isTrusted) return;
score++
this.classList.remove('up')
scoreBoard.textContent=score
}
moles.forEach(mole =>mole.addEventListener('click',bank))
>>: 每日挑战,从Javascript面试题目了解一些你可能忽略的概念 - Day29
上一篇我们有提到上图这些画了黄框的 files ,是我们在建立 editor 与操作 editor...
线上范例:JIT 线上范例 - Tailwind Play 因为 Tailwind CSS 的设计...
tag巢状结构 tag底下是可以再包tag的、底下可以再包tag... 昨天也看到一些例子如<...
集合其实和阵列有些相似,阵列是将相同资料型态的资料收集起来,而集合是收集一群相关资料,再以特定的类别...
原本要使用C3.js搭配D3.js套件制作动态图表,但不知为何一直无法正常抓取D3.js的cdn档案...