Can I use a ternary operator when I have more than one operation to perform per case?
For example can I use it here?:
if (dwelling) {
dwelling = dwelling[0].nodeValue; //first operation
letterDwelling = dwelling[0].toUpperCase(); //second operation
} else {
dwelling = "";
letterDwelling = "";
}
I've only used this syntax which allows one subsequent operation:
dwelling = dwelling ? dwelling[0].nodeValue : "";
Although i highly advice against it for the sake of readability and extensibility you could:
To avoid the side effects using the comma-notation you could use self-invoking functions instead which can handle your code:
Yes, see: Conditional (ternary) Operator
jsfiddle example