DEV Community

loading...

Discussion on: JavaScript Baseball

Collapse
denvercoder profile image
Tim Myers Author

It already calculates for a hit. How would there be any runs if there are not hits. 😂

There is a random chance of:

  1. hit
  2. Strike
  3. Ball
  4. Foul

It will actually advance innings and score runs if there are more than 3 hits in an inning.

Collapse
raddevus profile image
raddevus

Yeah, that makes sense. I think it's because the article didn't mention the possibility of a hit, just this :

Then a random number generator will either make that pitch a "strike", or a "ball". Once you get to 4 balls the batter is "walked". If you get 3 "strikes" the batter is out.