$back.addEventListener('click', () => {
const prevData = history.pop();
if (!prevData) { // 되돌릴 게 없으면 종료
return;
}
$score.textContent = prevData.score;
data = prevData.table;
draw();
});
(중략)
function moveCells(direction) {
history.push({
table: JSON.parse(JSON.stringify(data)),
score: $score.textContent,
});
(중략)
}