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

175
Visualizações
TypeError TypeError: Cannot read properties of undefined (reading 'length') for Twitter bot
// function to generate a random tweet tweet
function ranDom (arr) {
  var index = Math.floor(Math.random()*arr.length);
  return arr[index];
};

This is the code used

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

0

Works fine here:

function ranDom (arr) {
  return arr[Math.floor(Math.random()*arr.length)];
};

var items = [254, 45, 212, 365, 2543];
console.log(ranDom(items));

about 4 years ago · Juan Pablo Isaza Relatório

0

In general, you can add this line in the start of your function

if (arr === undefined){
    return DEFAULT_VALUE; \\define your default value for this case..
}

to handle this case.

But you need to investigate why your arr is undefined from the function call.

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