const field = document.querySelector('.field');
var opened =[];
var matched = 0;
var moves = 0;
function init(){
const cards = document.querySelectorAll('.card');
cards.forEach((card) => {
card.addEventListener('click', ()=>{
card.classList.add('opened');
})
})
var newArr=[];
matched = 0;
moves = 0;
//newArr = shuffle(Array.from(cards));
newArr = shuffle([...cards]);
for(let i=1; i<newArr.length; i++){
field.append(newArr[i]);
}
}
function shuffle(newArr){
console.log(newArr);
for (let i = newArr.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[newArr[i], newArr[j]] = [newArr[j], newArr[i]];
}
return newArr;
}
init();