lundi 21 septembre 2015

Javascript- Uppercase letters to lower case and vise versa

I am interested in making any uppercase letters lowercase and any lowercase letters uppercase. If I have code like the below code, what should I put in the blank spaces of this if/else statement: if (string[i] == ) and the else if (string [i] == ). Here is the rest of my code:

      var sentence = "Whats Up! MAKE ME uppercase or LOWERCASE";

      var theString = sentence.split("")

      for (var i = theString.length; i >= 0; i--) {

        if (theString[i] == ) {

          theString[i].toLowerCase();

        }

        else if (theString [i] == ) {

          theString[i].toUpperCase();

        }

      }

      var connectedSentence = theString.join("");

      console.log(connectedSentence);

Have I made any other mistakes? The expected output is make me UPPERCASE OR lowercase

Aucun commentaire:

Enregistrer un commentaire