flipped my read/write js ternary