Requirements:Make sure that the first letter of each word in the string is capitalized, and the remainder is lowercase.Here I have written two methods, or one method, and the other is a variant of the method.The first type:function titlecase (str) {
Solution Ideas
Convert a string to lowercase
To split a string into a string array
Loop array capitalize each word first letter
Converts all elements of an array into a string
The first of these methodsfunction Titlecase
//1 People wrote it, and I took it for reference.functiontitlecase (str) {varArray = Str.tolowercase (). Split (""); for(vari = 0; i ) {Array[i]= Array[i][0].touppercase () + array[i].substring (1, array[i].length); } varString = Array.join ("");
Requirements:Make sure that the first letter of each word in the string is capitalized, and the remainder is lowercase.Connectors like ' the ' and ' of ' are the same.Results:
titleCase("I‘m a little tea pot")should return a string
The following small series will introduce some basic algorithm questions about characters and arrays in JavaScript. I think this is quite good. Now I will share it with you and give you a reference. Let's take a look at the fcc issue recently. Just
About some basic algorithm questions about characters and arrays in js, and about js array Algorithms
Recently, I have been playing the fcc review. It's just like upgrading an instance. It's quite attractive to me. Today, I took the time to ping the
In this blog, "Python string series," The following is covered:
Python built-in STR objects and operations
Formatting of strings
Unicode strings in Python
Regular expressions in Python
Re module
This article describes
Original linkFlip String Algorithm Challengefunction reverseString(str){ str = str.split(‘‘).reverse().join(‘‘); return str;}reverseString("hello");First, convert the string into an array, and then use the reverse method of the array to flip the
Recently in the brush FCC problem, as the upgrade hit strange, a close to the past, but also quite attracted me. Today take time to Basic algorithm scritping This part of the problem, according to some hints, or relatively simple. Some problems to
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.