var filterKeys = ["hello this is javascript", "Movies"];
var title= "Hello"
searchKeyInNo = keySearch(filterKeys, title)
function KeySearch(filteredArray, searchKey) {
var flag=0
for (var i = 0; i<filteredArray.count; i++) {
//array operations
flag=1
}
return flag
}
var filterKeys = ["hello this is javascript", "Movies"];
var title= "Hello"
searchKeyInNo = keySearch(filterKeys, title)
function KeySearch(filteredArray, searchKey) {
var tempArray = filteredArray
var flag=0
for (var i = 0; i<tempArray.count; i++) {
//array operations
flag=1
}
return flag
}
Can we use passed array as paramneter as a function array?
Can we pass and use the entire array as argument?
I even tried the second piece of code that I added a new array to copy the argument array to process the function scoped array.
UPDATE: VS Code never showed up suggestion for argumentarray.length. Thanks. WORKS NOW!
Try this. You were using .count instead of .length on the filtered array to get the count of elements.
function KeySearch(filteredArray, searchKey)
{
var flag=0
for (var i = 0; i<filteredArray.length; i++)
{
if(filteredArray[i].toLowerCase()
.includes(searchKey.toLowerCase()))
{
flag++
}
}
return flag
};
console.log(KeySearch(["hello this is javascript", "Movies"], "Hello"))