O'Reilly logo
  • Ahmed Elgendy thinks this is interesting:

The generateShipLocations function

Let’s get started with the generateShipLocations method. This method iterates, creating ships, until it has filled the model’s ships array with enough ships. Each time it generates a new ship (which it does using the generateShip method), it uses the collision method to make sure there are no overlaps. If there is an overlap, it throws that ship away and keeps trying.

One thing to note ...

From

Cover of Head First JavaScript Programming

Note

Look at this example of DO While loop!!