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

347
Views
toLocaleLowerCase() is not a function

when I use this function it gives me an error that it is not a function.

<div id="cards_main"></div>
let arry = new Array();
for (i = 0; i < 2; i++) {
  if (document.getElementsByTagName("input")[i].value != "") {
    for (cards of arry) {
      if (cards.naming.toLocaleLowerCase().startsWith(document.getElementsByTagName("input")[i]).toLocaleLowerCase()) {
        document.querySelector("#cards_main").innerHTML = "";
        addCard(cards);
      }
    }
  }
}

Note that the array is not empty

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There are a few issues in your code.

The .startsWith() method returns a boolean of true or false, and expects a string. In your case you are passing a HTML element to it.

Try instead:

.startsWith(document.getElementsByTagName("input")[i].value)

.toLocaleLowerCase() should be run on a string type, but you are running it on a boolean.

if (cards
      .naming
      .toLocaleLowerCase()
      .startsWith(document.getElementsByTagName("input")[i]) // This returns a boolean
      .toLocaleLowerCase() // But this line isn't valid on a boolean
    ) {

You likely wanted to call toLocaleLowerCase on your input value.

Try this code instead:

const inputValue = document.getElementsByTagName("input")[i].value;
if (cards.naming.toLocaleLowerCase().startsWith(inputValue.toLocaleLowerCase())) {
  // ...
}
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!