Two Sum Algorithm Javascript Foreach With Asynchrony Waveform