Dealing with callback functions in loops in Javascript | Hacker News Reader