カードの扱い(JavaScript)
'use strict'; /* window.onload=function(){ function Card(suit,num){ this.suit=suit; this.num=num; this.front; this.setFront=function(){ this.front=`${this.suit}${('0'+this.num).slice(-2)}.gif`; }; } */ window.onload=function(){ class Card{ //コンストラクタ作成 constructor(suit,num){ this.suit=suit; this.num=num; this.front=`${this.suit}${this.num<10?'0':''}${this.num}.gif`; } } //カード配列作成 const cards=[]; const suits=['s','d','h','c']; for(let i=0;i0){ let index=Math.floor(Math.random()*i--); let temp=cards[index]; cards[index]=cards[i]; cards[i]=temp; } } //シャッフル実行 shuffle(); //テーブル作成 const table=document.getElementById('table'); for(let i=0;i 0){ msg=`残り:${remain}枚`; } else{ msg='Crear!!'; clearInterval(timerId); } info.textContent=`${msg}(${time}s)`; } function countStart(){ timerId=setInterval(()=>{ time+=1; showInfo(); },1000); } countStart(); };