Write js flogic