I am trying to figure out a way to write below code using functional programming.
let member_found = [];
// going through 50 or more pagination until 5 are found.
while(member_found.length < 5)
{
let member = findMember(/* calls selenium commands to visit next page */);
if(member != undefined)
member_found.push(member);
}
console.log(member_found) // expecting 5 values but actual is 0.
currently, the code goes into infinite loop due to non-blocking nature of js.
findMemberan async function or doesit take a callback?let member = findMember(he's maybe just missing an await, otherwise that's not an async method..to visit next pageora lot of selenium callsorcalls selenium commandsis absolutely nothing to do with logic and very unclear context. Perhaps webpage stuff? If you comment to the code. Better not to use words of unclear context.findMemberIt's aweful manner not to speficy the key function.pseudo codedoes not mean to cut the core information. You add unnessary keywrords - pagenation, lots of calls, selnium command, but the most important information is hidden. Rewrite the code.