What are the problems that could occur declaring a variable inside an if condition twice?
I understand that this is not the best way of doing it!
I know I can declare the variable outside the if condition.
I'm not looking for a solution! I'm not looking how I can declare my variables. I want to understand why this is a bad approach to declare the a variable inside an if-condition block.
/* Yes I know I can just have condition instead of condition === true,
this is only for simplicity */
if(condition === true){
var StuckUps = "over 9000";
}else if(condition === false){
var StuckUps = "Nothing";
}
alert(StuckUps) /* Yes I can access it outside the if condition!*/
Why would this be a bad habit if only one condition will be executed, so that means the variable will be declare only once anyway. What are the REAL problems with it?