Let's add in an event listener for starting the game so we've got our start game object that we created
in the previous lesson, adding an event listener to that event listener that we're adding in is a click.
We'll do an anonymous function.
So containing all of the functionality that we need on the click within this set of code here.
So what do we want to happen?
And one of the things that we want is we want to take that start game object and update its style properties
to be display none because we don't want the user to have the ability to click the button again.
So only one click of that start button.
So let's try that out.
Click and it disappears.
Still on the page, but it's being displayed none.
Let's also create a random wait time, random time using math, random method from JavaScript.
We can multiply it by 2000 and then we'll add 1000.
So we always have at least 1000 milliseconds or one second before we start the game and we make the
item.
So setting up the set time out.
And what this will do is this will execute a function or a code snippet after a specified delay so we
can call it make item the function and random time is the time period that it's going to wait until
it executes the function.
So what this is going to do whenever we press that start button, it's going to select random time.
So it could be anywhere from one to three seconds and it's going to start the process of having that
element show up that we have to click and timing that element as well.
Next, let's set up a function that will make the item, and this is where all of the gameplay will
take place.
So add that ability to start the game with the start button, set up a blank function to make the item.
And coming up next, we'll show you how to complete the game and the gameplay.