Fixed a loop bug (wrong iteration variable) in bfs/js