The String Object

The String object enables manipulation and formatting of text strings and also enables substrings within strings to be found.

The toUpperCase and toLowerCase Methods

Two of the simplest methods of the String objects are toUpperCase and toLowerCase. Here is a simple example in which the text inputted into a prompt box is converted to uppercase (shown in Figure 9.13):

<script language="JavaScript">
<!-- Cloaking device on!
inpTxt = prompt("Enter some text","HERE!");
alert(inpTxt.toUpperCase());
// Cloaking device off -->
</script>
Figure 9.13. A string is converted to uppercase.

And here is an example in which the text is converted ...

Get JavaScript™ 1.5 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.