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

How displayHit and displayMiss work

So we just talked about this, but remember, to have an image appear on the game board, we need to take a <td> element and add either the “hit” or the “miss” class to the element. The former results in a “ship.png” appearing in the cell and the latter results in “miss.png” being displayed.

image with no caption


Cover of Head First JavaScript Programming


How to add an image (which is an element) to another element? A tip: every element exists or could exist at some point in the flow of the application is given either a class or an id or both.