As you can see from the example, I passed a variable called snoop to coincide for the word argument in the function. I want whatever value I put in for word to be put under the same type of meta-characters. The problem is that every time I try to put meta-charaters around word ie. ( var snoop = new RegExp( /\bword/, 'gi' )) for example, it doesn't work. What would be the proper way to code this?
var gill = ['airplane','airport','apple','ball']
function auto (word, array){
var geo = array.join(" ")
var snoop = new RegExp(word, 'gi' )
var gip = geo.match(snoop)
console.log(gip)
}
auto("ai", gill)