For Loop in Unit 5 Lesson 3 causing issues with App

Hello,

I am trying to make an app similar to the physical game whack a mole.

function moleLoop (){
timedLoop(3000, function(){
moleNum = randomNumber(1, 10);
console.log (moleNum);
displayMole ();
setTimeout (function () {
hideMoles;
}, 2000);
if (score === 10) {
stopTimedLoop ();
}
});
}

Link to the project or level: [https://studio.code.org/projects/applab/Jqvs5iO69V3ysBxusTi8aX_UbqEsLn7zuLIZpPJ4xZ0]
What I expect to happen: [ Before I made a timed loop to loop the appearance of moles, I have code that states that when a mole is clicked, it gets set to hidden using the hideElement ID.

Does the setTimeout function work within a timed loop, or is there a different way to go about having them disappear after 2 seconds?

I also stated that when the score is equal to 10, it stops the timed loop, and eventually will start a faster-timed loop so the moles disappear faster. I attached the loop code, as well as the whole project for reference.]

What actually happens: [Now, once the mole appears, when clicked it carries out the function and adds a point like it is supposed to, but does not disappear, as it did before the loop was created.

Also, the loop works by showing the mole and changing the number as intended, but the Timeout function I have in the loop doesn’t seem to slow it down. ]
What I’ve tried: [I’ve tried to take out the loop and the program runs somewhat, but the hide & unhiding of the mole doesn’t function correctly and the 2nd faster loop doesn’t work. The more I add and take away the less I get with the coding. I am super confused. ]

Please help,
Jennifer

Hi @jangel,

Were you able to fix the issue? The game seems to work flawlessly and does exactly what you described you expect to happen. The moles disappear when clicked and the pace quickens after 10 points.

Let me know if this isn’t the case for you.

Also thanks for being so thorough with your description of the problem and for sharing the link - definitely helps with troubleshooting!

Frank