JavaScript: condition branch