Else if statements question

working through the javascript projects helped me understand i dont have a full grasp on the elseif statement. i guess i just havent used em enough. got through with single if or if - else with most of my challenges.

as of my understanding multiple single if statements will go will always go thourhyg the next if structure once the previous iff statement is evaluated. but when u chain an else if. there are times when the next else if is skipped. i thought all else if gets executed no matter what. so my question is. what must be the condition in order for the next elseif to be executed?

In short: The else-if chain stops as soon as JS finds a statement that evaluates to true. It’ll run the code in that block and exit the whole chain afterwards. Does that answer your question?

oh i see so if one statement is true? it doesnt go through the entire chain? well knowing that would of saved me alot of headache and time spent on the telephone validator project. but i do know now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.