Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Conditional statement

Biju_PhilipBiju_Philip TXMember Posts: 4
edited June 2016 in JavaScript

I am learning about the conditional statement in my JavaScript course and I came across the compound conditional statement and nested conditional statement. Could anyone explain the difference and how it could be used, maybe with some examples?

Best Answer

  • B00B00 Member Posts: 94 ✭✭✭
    edited June 2016 Accepted Answer

    Compound statements are statements using two or more logic operations.
    if (condition1 && condition2) { /* stuff */ }

    Nested are just what it says on the tin, they're statement block within statement block.
    if (condition1) { if (condition2) { //stuff } }

    Both examples yields the same result here. You'll use both types in more complex scenarios.

Answers

Sign In or Register to comment.