is there lodash function takes array of needles, , searches string (haystack) @ least 1 match? example:
let needles = ['one', 'two', 'three'] let str = 'one in every thousand quit jobs'
i need search str
see if contains @ least 1 of needles
. can implement without lodash, if there's function out i'd rather not reinvent wheel have lodash loaded project.
use
array#some
, thesome()
method tests whether element in array passes test implemented provided function.
let needles = ['one', 'two', 'three'] let str = 'one in every thousand quit jobs'; let bool = needles.some(function(el) { return str.indexof(el) > -1; }); console.log(bool);
Comments
Post a Comment