Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

434
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda