結果 : javascript wait for function to finish in loop