Untitled
unknown
plain_text
3 years ago
561 B
10
Indexable
let array = [[5, 3, '-'],
[6, '-', '-'],
['-', 9, 8]];
const arrNumbers = [1,2,3,4,5,6,7,8,9]
const foo = arr => {
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]);
}
}
// console.log(array[1][0]);
return [hollowCellsIndex, usedNums];
};
console.log(foo(array));Editor is loading...