Condition Builder in JavaScript