Conversion of uppercase and lowercase letters

Source: Internet
Author: User

The following methods are available in string:

1. touppercase () converts each letter in the string into uppercase letters.

2. tolowercase () converts each letter in the string to lowercase.

Using these two functions, we can convert English strings into uppercase and lowercase letters.

VaR STR = 'tracy '; toupper (STR); // convert to upper-case function toupper (STR) {var result = Str. touppercase (); console. Log (result );}
// Convert it to lower-case var SSTR = 'lil'; tolower (SSTR); function tolower (SSTR) {var result = SSTR. tolowercase (); console. Log (result );}

 

One question: Convert the first letter of each word into uppercase letters in the input string (containing multiple words.

// Convert the first letter of each word in the string to uppercase var words = "I am a student. "; changefirstletter (words); function changefirstletter (words) {var arr = words. split (""); For (VAR I = 0; I <arr. length; I ++) {arr [I] = arr [I]. charat (0 ). touppercase () + arr [I]. slice (1);} return console. log (ARR. join (""));}

 

Conversion of uppercase and lowercase letters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.