結果 : javascript wait for function to finish before continuing