Skip to content

Instantly share code, notes, and snippets.

View Anna-Myzukina's full-sized avatar
💭
if you NEVER try } YOU`LL never KNOW

Anna Muzykina Anna-Myzukina

💭
if you NEVER try } YOU`LL never KNOW
View GitHub Profile
function cavityMap(grid) {
// Turn grid into a 2D array
const twoDArr = grid.map(ele => ele.split(''));
// Loop through 2D array checking values against neighbours
for(let i = 1; i < twoDArr.length - 1; i++) {
for(let j = 1; j < twoDArr[i].length - 1; j++) {
if(horizontalCheck(twoDArr, i, j) && verticalCheck(twoDArr, i, j)) {
twoDArr[i][j] = 'X';
}