위도 경도 세팅 후 결과 값에 따라 루프 빠져나가기 문의

지도/로컬 API에 대한 문의게시//주소로 위도/경도 찾기
function codeAddress() {
var geocoder = new daum.maps.services.Geocoder();

$("input[name=resrceAdres]").each(function(idx){
	var adres = $(this).val();

    if(adres !== "") {
		geocoder.addressSearch(adres, function(result, status) {
			
			// 정상적으로 검색이 완료됐으면
		    if (status === daum.maps.services.Status.OK) {

		    	for(i=0, n = result.length; i < n; i++) {
				
					document.getElementsByName('resrceLa')[idx].value = result[i].y;
					document.getElementsByName('resrceLo')[idx].value = result[i].x;

					break;
		    	}
			} else {
				
			  //alert("geocode was not successful for the following reason: " + status);
			  //alert("주소 : " + adres + " 위/도 경도 값을 찾을 수 없습니다.");
			}
		});
	} //end if adres !== ""
});

}

루프 돌면서 위도 경도 세팅하는 로직인데요
위도 경도 세팅이 안돼는 주소인경우에 메세지 보여주고 루프를 빠져나가고 싶은데 아무리 해도 안돼네요
해결 방법이 있을까요

아래 답변처럼 addressSearch를 비동기 API를 promise로 감싸주세요.
status가 정상이면 값을 반환하고
그 외 status는 reject해서 catch문으로 문구를 출력하거나

status가 정상이 아닌 경우 빈 값을 반환하고
반환된 값이 없는 경우 반복문에서 return을 하는 방법이 있습니다.