Dragon slayer: Second if/else


#1

What is the work of this else statement in the second if statement?
I’m getting result without this else. Then what it does?

else
{
youHit = Math.floor(Math.random()*2);
}


#2

it gives you a 50% change to hit again

if you don’t insert this code, you will always hit the second, third and fourth hit (if first hit is a hit)

now you have a 50% change to hit on the second attempt to hit the dragon. This makes the game more balanced


#3

sorry… I cant get your answer sir. Will you elaborate how?


#4

What do you not understand? To make me helping you more effective, you need to explain What you do and do not understand

We might need several hits to kill the dragon, ik we don’t calculate youHit again we Will just keep hitting till dragon is dead

Recaclulating youHit Will gives 50% change to hit oh the second hit

You do understand that youHit gives 50% to hit and 50% to miss the dragon? Ik we miss, the dragon Will kill us


#5

Thank you for your kind respone,Sir.
i got it!!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.