nested if else questions in javascript