So this is a very important part and what's happening within the game, because it allows the player
to move next and we always have to make sure that we've got the proper messaging to the player so they
can understand what's happening as well.
So what we've done is we've muted the selected case and we also want to mute it within the side menu.
So let's figure out how we can select it from the side menu.
So console log.
And we've already tracked this within an array, within a global array.
So we've got one called side vowel.
So see what that looks like.
So we go into the game, select a case, and then now within the console, it's pay attention to what's
contained within the site menu.
So if we click one, we see that we've got all of these elements are selected.
So these represent all of the elements along the side that we can update and we can hide if we want.
And that's why it's nice and neatly presented.
And it's actually in the same order as we pulled it out, because as we're looping through and building
the view, we were adding those values in.
So they were using those same object values and that was all contained within that site value array.
And that's why it's going to be really easy now to grab that element and highlight it.
So we've got the side value array and we also pick up the index value and this is the index value that
was coming from the original.
So under here, we're tracking that index value.
So this was index two, so coming from the target value.
So we know that we passed that and we're also can pick that up and use it.
And that means that we can do what we did before, where we've got the class list and add and we're
going to add the muted class to it.
So basically it should hide the class.
So select a case and notice that on the first round, first round of the game, we don't want to hide
any of these because we don't want to give the player an indication of what values are, where or what
they've selected.
So we can't hide it on the first round.
But now when I select them, that one was 20, that one was eight.
And we also need still a pop up for the user to in order to know what was what value was actually contained
in there.
So within the coding, we know what's happened, but we don't know what's happened for the user when
the user's playing.
So going back into message and popping up this value, we could do the easy target.
So either one again, same thing value.
So that's going to be within the pop up message.
And now let's construct the message where we're going to pick up and determine whether this is good
or bad, because usually we have an indication whether their selection is good or bad.
So we're going to see that make sure that it's found in the games so that it actually does have an index
value.
And if it isn't found in the Games, then we know something's something's wrong there.
Something's gone bad and we could throw an error or we could do something at that point.
So now that we know that we've found it and the same thing that we did where we were splicing from the
game holder thing for this simply spliffs, so that value of the holding array and we don't need to
track it anywhere because this has just been removed out and we already know what value that is actually,
because we're the ones that found it in the area with the index.
So we're moving it out of the holding array.
And let's also do a quick check for target and value and we're going to check to see if it's less than
10.
And that would mean that depending on where it is, what the section is, and you can also update this
to be more dynamic so we can check to see if it's less than halfway through the length.
So we want to do ten and we ultimately want to get the value of ten.
And if it is, then our message is going to be with an H1 of great job.
And you can also have customized messages, even have an array of different messages.
And if it's not, then the message is going to be that's bad news.
So too bad.
So let's see how this works.
And so far, so we select our case.
We get three and we see that message is not defined.
So we need to define the value for message.
So going back up to where we've got the selection of the case, let's define variable message and let's
let's just keep it blank for now.
So make sure that we do have the variables before we try to use them.
So great job ten and great job two.
So that looks good.
And we're setting up messages, but we're telling the user what's happening.
So we want to make this dynamic and how do we get the value of ten?
We want to get the length of the value array, pick up the one that's halfway in there.
So we want to get that.
Value of ten and creating a variable for that, and I'll just call this halfway, because we want to
determine what the halfway value is from the Valory.
So we've got the Vallerie and we know that we can get a length out of it and divide it by two.
And so this is going to be the index value.
We can use math round in order to round the value.
So that's that the value that we want to pick up, get the value from the array.
So we're getting an index value being returned back here.
And we also want to get the value that's associated with that index value.
So both of these should be value because we've got the record value.
So let's try this now and we select our case and we got number two.
So we are getting 10 being returned back there.
So 10 so perfect.
We were able to calculate that out.
So now we've got a dynamic check and a dynamic message depending on what the selection is popping up.
So go ahead and add this into your project.
And now there was quite a bit of stuff that we covered here.
So some of the really cool things with JavaScript, some of them we didn't exactly need because we can
pick it up from the value the element object.
So either one is fine.
You could use that from there or you could get from the event target present information to the user
and allow them to move on to the next step.
And the next step is that we need to set up the offers, because between all of these case selections,
we need to make sure that the user understands what's happening and that we are presenting them offers
throughout the game at the right time.
So that's coming up next.