Answer the question
In order to leave comments, you need to log in
Is JSlint right and why?
I decided to check my project with jslint (I hadn't used linters before).
Download jslint addin in VScode. All default settings.
I have this code (simplified):
if(true){
var newItem = 10;
}
else{
var newItem = 20;
}
var newItem;
if(true){
newItem = 10;
}
else{
newItem = 20;
}
Answer the question
In order to leave comments, you need to log in
Replace with let and see if your construct works.
In general, variables should be declared at the beginning of the function.
Also read about raising var. Two vars are simply meaningless.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question