Two Sum Algorithm Javascript Foreach With Asynchrony