I have this array 8x8 array which is supposed to represent a checkerboard.
var board = [['RS', 'H', 'RS', 'H', 'RS', 'H', 'RS', 'H'],
['BS', 'RS', 'BS', 'RS', 'BS', 'RS', 'BS', 'RS'],
['RS', 'BS', 'RS', 'BS', 'RS', 'BS', 'RS', 'BS'],
['BS', 'RS', 'BS', 'RS', 'BS', 'RS', 'BS', 'RS'],
['RS', 'BS', 'RS', 'BS', 'RS', 'BS', 'RS', 'BS'],
['BS', 'RS', 'BS', 'RS', 'BS', 'RS', 'BS', 'RS'],
['RS', 'BS', 'RS', 'BS', 'RS', 'BS', 'RS', 'BS'],
['F', ' RS', 'BS', 'RS', 'BS', 'RS', 'BS', 'RS']
];
I want to get the element F's row and column number I am trying to use a 4 loop
function getF(board) {
var i, j;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if(board[i][j] == 'F'{
return {row:1, col:j};
How do I do this to get the indexes of all H elements?
{row: x, col: y}