Old code:
restart("👎 Game Over. Try again!");
const restart = (text) => {
let cardData = randomize();
let faces = document.querySelectorAll(".face");
let cards = document.querySelectorAll(".card");
section.style.pointerEvents = "none";
cardData.forEach((item,index) => {
cards[index].classList.remove("toggleCard");
//Randomize
setTimeout(() => {
cards[index].style.pointerEvents = "all";
faces[index].src = item.imgSrc;
cards[index].setAttribute("name", item.name);
section.style.pointerEvents = "all";
}, 1000);
});
playerLives = 10;
playerLivesCount.textContent = playerLives;
setTimeout(() => window.alert(text), 100);
};
This works great in a popup window.
I need a pretty popup so i decided to use sweetalert2.
New code:
Swal.fire("👎 Game Over. Try again!");
But now "OK" button does not run the function Restart.
How to use restart with Swal.fire ?

>Solution :
Assuming that restart is a function that restarts the game, you could write the alert as follows:
Swal.fire("👎 Game Over. Try again!").then(() => {
restart();
});
You would also want to remove the logic from the restart function that previously fired an alert.