Search⌘ K

Solution to Sub-task: Creating MazeSolver

Explore how to create a MazeSolver class by extending the Grid class in JavaScript. Understand the use of inheritance with the extends keyword and constructor initialization via super, enabling you to build maze-solving algorithms that leverage existing grid properties.

We'll cover the following...

Creating MazeSolver

For this task, create a class MazeSolver like this.

Node.js
const Grid = require('./grid').gridClass;
// Create MazeSolver class below
class MazeSolver extends Grid{
constructor(arr){
super(arr); // initialize the grid
}
}
var arr = [
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
]
var maze = new MazeSolver(arr);
maze.printArray();

To ...