Currently, I am in the middle of a tutorial series and working on a project to develop a reaction tester. Despite conducting thorough research online, I am struggling with resolving two specific issues and could really use some assistance.
When the game starts and the shape is clicked, it should display the time until the click event occurs while generating a random shape with unique attributes like color, size, and position.
My main objective is to reset the counter every time the shape is clicked and ensure that the shape remains within the boundaries of the window at all times.
However, the current setup continues to increment the counter without resetting it after each click, resulting in scenarios where the generated shape extends beyond the visible window area, requiring users to scroll to locate it.
I have attempted different approaches such as changing
var timeUntilClick = +new Date() - currentTime;
to var timeUntilClick = "";
, but unfortunately, no success has been achieved so far.
If you would like to take a closer look at my code, please visit this JSFiddle link.