Solution: lb_pathfinder

JavaScript·1 min read·Apr 22, 2025

Here is the commented solution for this project.

Create the script

Create a file named lb_pathfinder.js.

$ touch lb_pathfinder.js

Set up variables

The objective of this part is to declare and initialize all the variables needed to calculate distances and record the best path between cities.

Declare a function named findShortestPath.

lb_pathfinder.js
function findShortestPath(graph, startCity, targetCity) {  //}

Declare a variable named distances to store the shortest known distances from the start city and initialize it with an empty object literal.

lb_pathfinder.js
function findShortestPath(graph, startCity, targetCity) {  const distances = {};}

Unlock the full program 🚀

Pay once, own it forever.

149

30-day money-back guarantee

  • 13 modules
  • 113 lessons with full-code examples
  • 29 projects with commented solutions
  • All future lesson and project updates
  • Lifetime access

By submitting this form, you agree to the Terms & Conditions and Privacy Policy.