str = str.replace(fraction, replacement[1] || replacement[0]);
I want to replace with [1] if [1] is not "" or undefined or null, or else replace with [0] if [1] is "" or undefined or null. I know I can do this with a 3-5 lines of if else, but can I do it in one like very short like I wrote above in Java?