s24344,
function escapeRegExp(string){
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function fn(arr, pattern) {
pattern = escapeRegExp(pattern);
pattern = new RegExp("^(" + pattern.trim().replace(/\s+/g, "|") + ")", "i");
return arr.filter(function(el) {
return Object.values(el).some(function(val) {
return pattern.test(val)
})
})
};