JS backend: fix generated code for ternary operator