Multiple Ways to Write Conditional Statements?

AhesletAheslet Texas
edited September 2016 in JavaScript

During a class assignment it occurred to me there are possibly multiple ways to write conditional statements to achieve the same result.
For example, I can write three if conditions with a greater than, less than, and equal to outcome. But could I not achieve the same result by using else? If x is less than y or if x is greater than y then else. How do I go about making else reliant upon two if conditions?



  • if (x > y) {
    // greater
    } else if (x < y) {
    // less
    } else {
    // equal
Sign In or Register to comment.

Howdy, Stranger!

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


In this Discussion