How can I assign a value to different variable based on a certain condition?
For example, if now the variable a is true, then I want to assign the string "Hello" to the variable b, but not the variable c.
But if now the variable a is not true, then I hope the string "Hello" could be assigned to the variable c, but not the variable b.
Is there a way to assign a value to different variable based on a certain condition in Javascript?
Like this:
var a = true;
var b, c;
((a) ? b : c) = "Hello";
console.log(b); //This should output "Hello"
console.log(c); //This should output `undefined`