Rerun until variable is defined

I am new to postman and also not very familar with JS. I have and API to get Area Codes. The API always returns a 200 ok, with either a list of numbers for that Area Code or a messaging saying invalid area code. My goal is to have the test rerun until a valid area code is found. I have tried several ways of getting this to work with no luck. I see that the variable response is undefined when area codes are returned. So I am trying to use that in conjuction with set.NextRequest() but again no luck. Please help. This is what I got so far.

Array.prototype.random = function () {
  return this[Math.floor((Math.random()*this.length))];

pm.test("Status code is 200", function () {;

    //returns random phone from response
    var phone_number = pm.response.json().random()

    const response = pm.response.json()['msg'];


    //if (response == undefined) 
    if (typeof response == "undefined") ;
        console.log("Did not find a match");
    } else {
        console.log("Found a match");
       pm.collectionVariables.set("phone_number", phone_number);