game-battleship
Version:
A battleship program
69 lines (46 loc) • 2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: utilities/helpers.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: utilities/helpers.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* Helper method to parse coordinates, this would parse the character on its ascii value
* @param {string} coordinates : these are the coordinates inside the player area. i.e. "A1"
* @returns {Array} It returns the parsed xand y coordinates
*/
function parseCoordinates(coordinates) {
const yCoordunate = coordinates.charCodeAt(0) - 65;
const xCoordunate = parseInt(coordinates.charAt(1) - 1);
return [xCoordunate, yCoordunate];
}
module.exports = {
parseCoordinates
};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Area.html">Area</a></li><li><a href="Player.html">Player</a></li><li><a href="Ship.html">Ship</a></li></ul><h3>Global</h3><ul><li><a href="global.html#battle">battle</a></li><li><a href="global.html#fileReader">fileReader</a></li><li><a href="global.html#parseCoordinates">parseCoordinates</a></li><li><a href="global.html#validateArgs">validateArgs</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 19 2019 14:14:50 GMT+0530 (India Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>