Using var in block-scoped contexts (e.g., if)
Using var in Block-Scoped Contexts (e.g., if) in JavaScript In JavaScript, the var keyword is function-scoped, meaning that variables declared with var are visible throughout the entire function, even outside….