title: how to get the following output of the code snippet?
body: <p>I have been asked this question in an interview. How to solve this? The object and consoles statements are mentioned. I am not getting how to implement the function findPath?
  <a href="https://i.stack.imgur.com/a3Nmd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a3Nmd.png" alt="Code snippet" /></a></p>