Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!