Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!