Return and Loops

Does the “return” command stop a loop if the statement is false ?
For example

for (let i = 0; i < contacts.length; i++) {
if (name == contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;

in the above scenario it should return “contacts[i].prop;” if the statement is True. But, what if it isn’t does it then go back into the loop ?


Does the “return” command always stop the loop

This makes so much sense, thank you !

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.