I have two variables foo& bar and I want to declare them based on a condition.
I have already shortened the code from this:
let foo = '';
let bar = '';
if (condition) {
foo = 'hi';
bar = 'bye';
} else {
foo = 'bye';
bar = 'hi';
}
To this:
const foo = condition ? 'hi' : 'bye';
const bar = !condition ? 'hi' : 'bye';
I still feel the code is repetitive with having to use ternary operator twice. Is there anyway I can shorten this code more? Thanks :)