Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
Javascript array.findIndex(x) TypeError: x is not a function

I am receiving the error `Uncaught TypeError: Lemon is not a function online with the following code

var guildList = [];
guildList.push("Lemon");
console.log(guildList); //some debugging code - I can see Lemon here
console.log(guildList.findIndex("Lemon"));

returns the error:

Uncaught TypeError: Lemon is not a function

I have attempted to check to make sure that the variable is a value (this case "Lemon"), however, this does not mitigate it.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

findIndex accepts a function. You are passing it a string.

Instead, pass a function which checks whether the parameter is equal to "Lemon":

function a() {
  var guildList = [];
  guildList.push("Lemon");
  console.log(guildList);
  return guildList.findIndex(e => e == "Lemon");
}

console.log(a())

Or use indexOf instead:

function a() {
  var guildList = [];
  guildList.push("Lemon");
  console.log(guildList);
  return guildList.indexOf("Lemon");
}

console.log(a())

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda