結果 : how to avoid infinite loop in javascript