This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | |
} |