Global variables for grid , minDistance and visited array
let minDistance = new Array ( row + 1 ) ; for ( let i = 0 ; i < row + 1 ; i ++ ) { minDistance [ i ] = new Array ( col + 1 ) ; for ( let j = 0 ; j < col + 1 ; j ++ ) minDistance [ i ] [ j ] = 0 ; } let visited = new Array ( row + 1 ) ; for ( let i = 0 ; i < row + 1 ; i ++ ) { visited [ i ] = new Array ( col + 1 ) ; for ( let j = 0 ; j < col + 1 ; j ++ ) visited [ i ] [ j ] = 0 ; }