Can there be an 'if statement in an if statement'?

So this is for a project I’ve been working on for quite a bit now, and there’s been a question in my mind that has been begging to be answered:

“Can there be an if statement inside of an if statement?”

Yep. It would be a great help if somebody answered my question!

  • Storydragon

Yes there can be. One name for them is nested conditional statements.
In python you might see

if foo:
    if bar:

In C and C-family languages you would see something like:

if (foo)
    if (bar)

what about javascript?

Yes, javascript is in the C-family syntax so the second example would work. (the bracketing convention might not be the same but the code snippet would run in js)

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