結果 : how to make one function wait for another javascript