Given I have an array of \"purpose\" objects:
//array of purpose objects:
var purposeObjects = [
{purpose: \"daily\"},
{purpose: \"weekly\"},
{pu
Javascript has a function just for that: Array.prototype.find. As example
function isBigEnough(element) {
return element >= 15;
}
[12, 5, 8, 130, 44].find(isBigEnough); // 130
It not difficult to extends the callback to a function. However this is not compatible with IE (and partially with Edge). For a full list look at the Browser Compatibility