This lesson, we're going to add randomness into the elements as they're being generated and we can
add this into our maker function.
As this is the best place as we're building out these elements, we're generating them, we can also
set the default values that the user has to guests.
And these are going to be hidden.
The backgrounds is going to be no way that the user is going to be able to tell what the values are
that we're looking for.
So let's add in one more object into our element, and this one can be correct.
So whatever the correct value is, and we don't need a function for this, we can use our math random.
Method in JavaScript, Somnath, random, and this is going to produce a random value for that particular
element, and then once we click the check combo, we can loop through all of the elements with a class
of NUM and check those to see if they match whatever the random value is that's being output here.
So let's try that out.
And first, mothe random.
We need to apply math flaw to get rid of the zeros and we also need to multiply math random by a number.
We're going to multiply it by ten.
So this will give us a random number anywhere from zero to nine.
And that's exactly what we want positioned here within our values.
And we can also for now use this same generator where instead of we're setting a value of zero, let's
set that correct value so that we can see it and we can see that is getting generated out.
So now when we click start, we get a random combination.
And this is actually the combination that we're going to have the user guessing.
So the next step is that we're going to set up the check convo button when the player clicks this button
instead.
Just typing checker.
We need to check to see where you need to loop through all of these elements.
And we see that all of them have a class of num.
So we're going to use query selector all select all of the elements with the class of NUM and loop through
them.
And as we iterate through them, we're going to check to see if the numbers are right.
And if they're not, then we're going to send out a message to the user so either that it's low or high
and we can do that with the background color.
So indicating that blue needs to be blue is too low and red is too high and then green is going to be
the background for the correct numbers.
So all of that is coming up in the next lesson.
This lesson, add in the math random.
And afterwards we're going to update the correct value and we're going to update the value back to zero.
So that's still to come in the upcoming lessons.
So go ahead and try this out for yourself.