結果 : javascript wait until function finishes