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);
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.