lundi 5 novembre 2018

Converting if...else statement to if...else if...else statement

How do I convert this nested if…else statement into a non-nested if…else if…else statement. You may need to add some Boolean operators to make this completely non-nested:

        if (ball > 0) {

      if (cup > 0) {

           console.log(“I have a ball and cup.”);

      } else {

           console.log(“I have a ball.”);

      }

 } else {

      if (cup > 0) {

           console.log(“I have a cup”);

      } else {

           console.log(“I have nothing”);

      }

 }

Aucun commentaire:

Enregistrer un commentaire