If without else?

Can I have four “ifs” with code between the else and another if?

So when I’m checking your answer to my question… if there’s no answer, I want to tell you to put one in.

So I want the “check” button to stay ‘live.’

If you’ve put an answer in, there are several options (if it’s right, do this; if it’s wrong, do that) – but for each of them, I want to turn off the ‘check’ button and turn on the ‘new problem’ button.

So I want to say … if (no answer) – do this.

Else … switch the buttons. .

if it’s right, do this.
If it’s wrong, do that.
https://codepen.io/geonz/pen/jOOwzmw is the pen; line 58 is where the checking function starts. (… and if this is off base b/c it’s not from a codecamp lesson, I apologize and will retreat :wink: – I’m trying to apply what I’ve learned…)

I don’t have the time to check your code now, but to answer your question: yes, you can have as many independent if/else if/else chains as you need. There can be only the if statement, the chains can be nested, they can be one after the other, etc. and each one will work independently from the others chain

1 Like