Why is the function outputting different results with the same input

I’m setting the values of this 4 x 4 grid to be exactly the same, yet when I run it through an A* pathfinding program it gives me different results

grid[0][0] = 0;
grid[2][2] = 3;

grid[1][1] = 1;
grid[1][2] = 1;
grid[1][3] = 1;
grid[2][1] = 1;

console.log(PathFind([0,0], grid));

grid[0][0] = 0;
grid[2][2] = 3;

grid[1][1] = 1;
grid[1][2] = 1;
grid[1][3] = 1;
grid[2][1] = 1;

console.log(PathFind([0,0], grid));

output 1:
[ ‘Right’, ‘Right’, ‘Right’, ‘Down’, ‘Down’, ‘Left’ ]

output 2:
[ false ]