I have an array that looks like this:
const list = [["GET", /github/g]];
It's an array with a sub array, index 0 having a string, index 1 having a regular expression.
I'm trying to do something like this:
function checkList() {
return list.find(i => i[0] === "GET" && i[1].test("github.com"));
}
Which I would expect to return the list it finds every time, but that's not the case, it flips back and forth from returning the list and returning undefined.
Here's an example:
let i = 1;
const list = [["GET", /github/g]];
while (i <=10) {
console.log(list.find(i => i[0] === "GET" && i[1].test("github.com")))
i++
}
In this example I just loop through it and log the results to show that it returns the list and undefined every other time. What's going on here?