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

348
Visualizações
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 Respostas
Responde à pergunta

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