[JS Practice] Name Array Capping (第一个字母大写)

Title :

Name Array Capping (第一个字母大写)


Create a method that accepts an array of names, and returns an array of each name with its first letter capitalized.


example :

capMe([<span class="string">'jo'</span>, <span class="string">'nelson'</span>, <span class="string">'jurie'</span>]) <span class="comment">// returns ['Jo', 'Nelson', 'Jurie']</span> 
capMe([<span class="string">'KARLY'</span>, <span class="string">'DANIEL'</span>, <span class="string">'KELSEY'</span>]) <span class="comment">// returns ['Karly', 'Daniel', 'Kelsey']</span>

My solution :

function capMe(names) {
  var retArr = [];
  return retArr;

 * This function translate 
 * @param : string
 * @return : stirng with first letter capitalized
function capFirstLetter(str) {
  return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1);

Ref. from codewars

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s