結果 : javascript loop wait for function to finish