String Function - case conversion
how to convert a lower case alphabet to upper case and vice versa in javascript?
Explanation
Object:
StringMethod or Function:
toLowerCase(), toUpperCase()Description: These methods are used to cover a string or alphabet from lower case to upper case or vice versa. e.g: "and" to "AND".
Converting to Upper Case:
Example:
<script language=javascript>
var ss = " testing case conversion method ";
var result = ss.toUpperCase();
document.write(result);
</script>
Result:
Converting to Lower Case:
Example:
<script language=javascript>
var ss = " TESTING LOWERCASE CONVERT FUNCTION ";
var result = ss.toLowerCase();
document.write(result);
</script>
Result:
Explanation:
In the above examples,
- toUpperCase() method converts any string to "UPPER" case letters.
- toLowerCase() method converts any string to "lower" case letters.