en
Home About project

Convert case with Javascript

If you need to convert a string to lower case or to upper case with Javascript you can use following properties of text variables:

  • toUpperCase()
  • toLowerCase()

toUpperCase
- returns value of the called line converted to upper case.

Example of converting to upper case using toUpperCase

var Str="hello, world!";
alert(Str.toUpperCase());

return the message with the text "HELLO, WORLD!".


toLowerCase
- returns value of the called line converted to lower case.

Example of converting to lower case using toLowerCase

var Str="Hello, WORLD!";
alert(Str.toLowerCase());

return the message with the text "hello, world!".

N.B.
It is important to remember that methods toUpperCase and toLowerCase do not modify an initial line, and the line is returned by function.