The final code

Our final codes will look similar to the following:

<html> <head> </head> <body> <h1> Battleship Game </h1> </body> <style> body { background-color: #eff; } </style> <script> var game = [ [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", ".", "."], ]; var board = document.createElement("PRE"); // preparing the HTML <pre> element to display the board on the page document.body.appendChild(board); ...

Get JavaScript Projects for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.