Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
Array as argument and using the array in the new function in javascript
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!

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

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"))

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda