Any and every return statement stops all further code execution in a function call immediately.
But yeah, having return "No such contact" in the middle of the loop is equivalent to saying “if you find someone that doesn’t match, give up, stop looking further, and assume you never will find anyone that matches”.
To help me understand better I inputted the data to chatGPT. I couldn’t understand why using the && operator combined with return contacts[i][prop] || "No such property" wasn’t working. I am assuming this is because the && operator is checking to see if both statements are true at the same time and not picking up the "No such property" statement. It is suggested that a second if statement is used instead.
I wouldn’t necessarily say it was chatGPT more like my wording and lack of understanding. I agree though I do try to to understand what is happening outside of chatGPT. I mostly use it has an assistant.
I think I finally understand what you are trying to convey to me. I believe it is just the test itself that needs to be written a certain way in order to pass, but as far as writing the code another way, their are other possibilities. Also, I understand from what you mentioned about return that a second if statement is needed so that the first if statement can continue running if the second statement returns “No such property”.