`var opened = [];
var matched = 0;
var moves = 0;
const field = document.querySelector(".field");
let cards = [...document.querySelectorAll(".card")];
function shuffle(arr) {
let newArr = [];
arr.forEach((el, i, arr) => {
let changeIndex = Math.trunc(Math.random() * arr.length);
el = arr[changeIndex];
arr[changeIndex] = el;
newArr.push(el);
});
return newArr;
}
function init() {
let shuffled = [];
moves = 0;
matched = 0;
cards.forEach((card) => {
card.addEventListener("click", (e) => {
card.classList.add("opened");
});
});
shuffled = shuffle(cards);
field.append(...shuffled);
}
init();
`
И снова здраствуйте. Что ж он хочет от меня?