Untitled

 avatar
unknown
plain_text
2 years ago
627 B
4
Indexable
const possibleNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];

const foo = (arr) => {
  let possibleNumCopy = [...possibleNumbers];
  let arrCopy = JSON.parse(JSON.stringify(array));
  let hollowCellsIndex = [];
  let usedNums = [];
  for (let i = 0; i < arr.length; i += 1) {
    for (let j = 0; j < arr[i].length; j += 1) {
      if (arr[i][j] === '-') hollowCellsIndex.push([i, j]);
      if (arr[i][j] !== '-') usedNums.push(arr[i][j]);
    }
  }
  let avalNums = possibleNumCopy.filter((el) => !usedNums.includes(el));
  console.log(arrCopy[hollowCellsIndex[0][0]])
  console.log(hollowCellsIndex[0])

};

console.log(foo(array));
Editor is loading...