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

95
Vistas
Should I use let in these codes?

I'm filtering my data and should I use let in storing the percentage or would it cause problems in the long run?

I plan to use this in the graph too.

const filteredUsers= data.filter((v) => v.items?.selectedItem == "Car");
const total = filteredUsers.length

const items2 = users.filter(
    (v) => v.items?.part1 == true && v.items?.part2 == true
  );

  let percentage = ((items2.length / total) * 100).toFixed(2);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Variables defined with let cannot be redeclared. With var you can.

ES6 introduced let and const. These two keywords provide Block Scope in JavaScript. Variables declared inside a { } block cannot be accessed from outside the block

Variables declared with the var keyword can NOT have block scope. Variables declared inside a { } block can be accessed from outside the block.

So the question is, can you use const or do you change the variable percentage somewhere again, and do you need the variable outside of your block.

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