DEV Community

Discussion on: 💡🎁 JavaScript Visualized: Generators and Iterators

Collapse
 
tstsankov profile image
TSTsankov

const findbook = (bookID) => {
for(var i=0; i<members.length; i++)
for(var j=0; j<member[i].Books.length; j++)
if(members[i].Books[j].id == bookID)
return members[i].Books[j];
}

findbook("ey812");

Shouldn't the return statement just finish execution if/when book is found?

Thread Thread
 
iversonlv profile image
iversonLv

I think so, for loop seems the same flow with generator function for above book club example.