Hello friends help me solve this. I have created search field with small regular EXpresion, but if i search through i get -1 as answer.
//the HTML
<form id="searchBox">
<input type="search" name="search" value="" placeholder="search" id="search">
</form>
//the javascript code
let searchBox = document.getElementById('searchBox');
searchBox.addEventListener('submit', el =>
{el.preventDefault()
// when search is submitted get the value from search fields;
let searchField = document.querySelector('#search').value;
let arrayBox = ['Cats','Cow','fish','Dog','Cats','fish'];
for (var i = 0; i < arrayBox.length; i++) {
let gSearch = '';
if (gSearch !== arrayBox[i] || gSearch !== -1){
gSearch += arrayBox[i].search(/searchField/i);
console.log(gSearch);
}else {
console.log('not yet here')
}
}
})