Function to test if any one of them matches with the given 2 - D array
function testGrid ( testGrid , Grid , N , M ) { for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 0 ; j < M ; j ++ ) { if ( Grid [ i ] [ j ] != " " ) { if ( Grid [ i ] [ j ] != testGrid [ i ] [ j ] ) { return false ; } } } } return true ; }