# battleship

The assignment is to re-create the popular board game battleship game using JavaScript.

Learn about the game and what the rules are here: <https://en.wikipedia.org/wiki/Battleship_(game>)

All the code the functions that are needed are outlined in the JS-file. No need to add more unless you want to. Read the comments in the code *carefully*.

## Step 1: Get started by reading through the battleship.js file. All that you need to solve the assignment is described in comments

## Step 2: Use the for-loops defined in the code to generate a grid.

References for the methods in JS that are needed for this step:

* [document.getElementById()](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById)
* [document.createElement()](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement)
* [appendChild()](https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild)
* [Style property in JS](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)
* [How to loop in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration)

## Step 3: Attach event-listeners to each square in the grid and trigger the guess() function on click

* [Event handling in JavaScript](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events)

## Step 4: Add the logic that's needed for the game to be playable

* [If-statments in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)

## Step 5: Play! Make sure you can win

A player should be able to sink all the ships, look in the js-file for the ship positions to make this easier to test.

BONUS tasks (optional):

* Add graphics, animation
* Add support for randomizing the grid
* Add support for resetting the game without having to reload the webpage
* Add support for multiplayer
