I am new developer
I have problem in this code, and don't know what the problem
My maze code working but is not solve the maze
can someone help me to understand what is the issue or there is a different ways to solve it ?
var myMaze = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 1, 0, 0, 1, 1, 1],
[0, 1, 0, 0, 1, 0, 0, 1, 0, 0],
[0, 1, 1, 1, 1, 0, 1, 1, 1, 0],
[0, 1, 0, 0, 1, 0, 1, 0, 1, 0],
[0, 0, 0, 0, 1, 1, 1, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 2],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
];
function maze(myMaze){
this.find = function(col,row){
console.log(row,col,myMaze[row][col])
if(myMaze[row][col] == 2){
console.log('done')
}
if(myMaze[row][col] == 1){
console.log('we on the right way')
if(row < myMaze.length - 1){
this.find(col,row+1)
}
if(col< myMaze[row].length -1){
this.find(col+1,row)
}
if(row > 0){
this.find(col,row-1)
}
if(col > 0){
this.find(col-1,row)
}
}
}
}
var maze= new maze(myMaze)
maze.find(0,3)