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

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

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