Breadth First Search Algorithm Leetcode Javascript Practice