Nested If Condition In Javascript