I am a brand new programming hobbyist. I decided to start with JavaScript because I am interested in Web Development. Working through some classes I have encountered something that really confuses me. What is the purpose of "else...if" when it seems that multiple "ifs" do the same thing. I've really tried to find this answer before I posted here. I've worked out several tests in the Chrome console. Thank You in advance.
It makes a difference when multiple conditions might hold. For example:
if (x) { do thing 1 }
if (y) { do thing 2 }
will do both thing 1 and thing 2 if x and y are both true. But
if (x) { do thing 1 }
else if (y) { do thing 2 }
will do only thing 1 if x is true, even if y is also true. It will do y only if y is true and x is false.