JSFiddle - React, Tailwind, and code Playground
JavaScript
var allItems = ["1", "2", "3"]
var allPeople = ["A", "B"]
var testFoo = function(itemValue, peopleValue) {
setTimeout(function(){
return itemValue == "3" && peopleValue == "B"
}, 200)
}
allItems.forEach(function(itemValue) {
allPeople.forEach(function(peopleValue) {
// I want to iterate through each object, completing testFoo before moving on to the next object, without recursion. TestFoo has a few instances of setTimeout. I've tried using promises to no avail.
if (testFoo(itemValue, peopleValue)){
alert("success")
} else{
// nothing
};
})
})
alert("fail")