I'm initializing a variable conditionally with if/else. I want to follow functional programming rules.
My eg.:
if (1 === 2) {
const a = false;
} else {
const a = true;
}
console.log(a);
Linter say: ESLint: 'a' is not defined.(no-undef).
As you know there is no way that a
would not be defined. Another approach could be:
const a = 1 === 2 ? false : true;
But what if there were three conditions in if/else? How do I achieve that and avoid error?