src/04-mine-sweeper.js
/**
 * In the popular Minesweeper game you have a board with some mines and those cells
 * that don't contain a mine have a number in it that indicates the total number of mines
 * in the neighboring cells. Starting off with some arrangement of mines
 * we want to create a Minesweeper game setup.
 *
 * @param {Array<Array>} matrix
 * @return {Array<Array>}
 *
 * @example
 * matrix = [
 *  [true, false, false],
 *  [false, true, false],
 *  [false, false, false]
 * ]
 *
 * The result should be following:
 * [
 *  [1, 2, 1],
 *  [2, 1, 1],
 *  [1, 1, 1]
 * ]
 */
In the popular Minesweeper game you have a board with some mines and those cells
that don't contain a mine have a number in it that indicates the total number of mines
in the neighboring cells. Starting off with some arrangement of mines
we want to create a Minesweeper game setup.

@param {Array} matrix
@return {Array}




In the popular Minesweeper game you have a board with some mines and those cells that don ' t contain a mine have a number in it that indicates the total number of mines in the neighboring cells . Starting off with some arrangement of mines we want to create a Minesweeper game setup . @param { Array } matrix @return { Array }
function minesweeper() {
  throw new Error('Not implemented');
}
function minesweeper ( ) { throw new Error ( 'Not implemented' ) ; }
In the popular Minesweeper game you have a board with some mines and those cells
 that don't contain a mine have a number in it that indicates the total number of mines
 in the neighboring cells.
In the popular Minesweeper game you have a board with some mines and those cells that don ' t contain a mine have a number in it that indicates the total number of mines in the neighboring cells .
/* matrix */ /*   const newArr = [];
  for (let i = 0; i < matrix.length; i++) {
    let arr = [];
    for (let j = 0; j < matrix[i].length - 1; j++) {
      let arrFirst = [];
      let arrSecond = [];
      let arrThird = [];

      if (i - 1 === -1) {
        arrFirst.push(0, 0, 0);
      } else {
        arrFirst = [
          matrix[i - 1][j - 1],
          matrix[i - 1][j] || 0,
          matrix[i - 1][j + 1] || 0,
        ].reduce((acc, el) => (el === true ? acc + 1 : acc), 0);

        arrSecond = [matrix[i][j - 1], 0, matrix[i][j + 1]].reduce(
          (acc, el) => (el === true ? acc + 1 : acc),
          0
        );

        arrThird = [
          //  matrix[i + 1][j - 1],
          matrix[i + 1][j],
          matrix[i + 1][j + 1],
        ].reduce((acc, el) => (el === true ? acc + 1 : acc), 0);
      }

      arr.push(arrFirst + arrSecond + arrThird);
    }
    newArr.push(arr);
  }

  return newArr; */