The problem I'm trying to solve is quite simple but since there are a lot of (hidden) magic functions in javacript I'm wondering if there is a quick solution for that. So far I've only seen people trying to know if an array contains a string (boolean) but that's not what I'm trying to achieve.
I have a simple string array :
var myarray = [ "word1", "word2", "potatoe"]
If I'm looking for the substring "word", I would like to write a function that returns a new array which only contains the matching elements of the original array. In that case it would be : ["word1", "word2"].
What's the best approach, do I have to loop and create the new array by hand ?
Thanks