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

433
Visualizações
eslint for loop 'i' is not defined

I am pretty new to eslint and I am updating my code to fit my eslint file.

module.exports = {
  env: {
    browser: true,
    commonjs: true,
    node: true,
    es2021: true,
  },
  extends: 'eslint:recommended',
  parserOptions: {
    ecmaVersion: 'latest',
  },
  rules: {
    indent: ['error', 2],
    'linebreak-style': ['error', 'unix'],
    quotes: ['error', 'single'],
    semi: ['error', 'always'],
  },
};

I have a for loop and eslint is saying that 'i' is not defined.

  for (i = 0; dbl.length > i; i++) {
    arr.push(dbl[i].Author); 
  }

To my knowledge when using a for loop you are supposed to init a var in the first part, however I'm not sure.

Am I doing for loops wrong or is there something I am missing with eslint?

All help is appreciated, thank you!

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

0

You have to declare the variable first. Follow the code below.

  for (let i = 0; dbl.length > i; i++) {
    arr.push(dbl[i].Author); 
  }

I think you got the point.

about 4 years ago · Juan Pablo Isaza Relatório

0

You problem is unrelated to eslint. You need to define i before you can use it.

// note the `let` before the `i`
for (let i = 0; dbl.length > i; i++) {
    arr.push(dbl[i].Author); 
}
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