text: import { NotImplementedError } from '../extensions/index.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]
   * ]
   */
  export default function minesweeper (matrix) {
    // throw new NotImplementedError('Not implemented');
    // remove line with error and write your code here
    let arr1 = [];
    matrix.forEach(function(item1,index1) { 
      let arr2 = [];
      item1.forEach(function(item2,index2) {
        let sumTrue = 0;
        if(matrix[index1-1]) {
          if (matrix[index1-1][index2-1]) {
            sumTrue++;
          }
  
          if (matrix[index1-1][index2]) {
            sumTrue++;
          }
  
          if (matrix[index1-1][index2+1]) {
            sumTrue++;
          }
        }
          if (matrix[index1][index2+1]) {
            sumTrue++;
          }
        if(matrix[index1+1]) {
          if (matrix[index1+1][index2-1]) {
            sumTrue++;
          }
          if (matrix[index1+1][index2]) {
            sumTrue++;
          }
          if (matrix[index1+1][index2+1]) {
            sumTrue++;
          }
        }
          if (matrix[index1][index2-1]) {
            sumTrue++;
          }
        arr2.push(sumTrue);
      })
      arr1.push(arr2);
    })
  
    return arr1;
  }
  