I am trying to complete a project for my course, it is a game wrack the mole. I am following a tutorial but still, my code is not working, I have gone through the code many times but still can’t find the mistake. Any help will be great.
// get a random cell,
var cells = document.getElementsByTagName ("TD")
var randomIndex = Math.floor(Math.random() + cells.length)
//mole appear on cell
var randomCell = cells[randomIndex]
var mole = document.createElement('img');
//source of mol picture
mole.src ='./mole.PNG';
mole.id = "mole";
randomCell .appendChild (mole)
mole .onClick = whackedMole;
// click on mole and than mole appear on different cel
function whackedMole(){
randomIndex = Math.floor(Math.random() * cells.length)
randomCell = cells.randomIndex
randomCell.appendChild (mole)
//audio for mole
var audio = new Audio('./whack-audio.wav')
audio.play();
}