美文网首页
Title Case a Sentence

Title Case a Sentence

作者: s1xteenth | 来源:发表于2017-03-12 21:28 被阅读0次

确保字符串的每个单词首字母都大写,其余部分小写。

像'the'和'of'这样的连接符同理。

function titleCase(str) {
  var newstr = str.split(" ");
  var Str = newstr.map(function(val){
    var tmpArray = val.toLowerCase().split("");
    tmpArray[0] = tmpArray[0].toUpperCase();
    return tmpArray.join("");
  });
  newstr = Str.join(" ");
  return newstr;
}

titleCase("I'm a little tea pot");

相关文章

  • Title Case a Sentence

    句中单词首字母大写 确保字符串的每个单词首字母都大写,其余部分小写。 像'the'和'of'这样的连接符同理。

  • Title Case a Sentence

    确保字符串的每个单词首字母都大写,其余部分小写。 像'the'和'of'这样的连接符同理。

  • Title Case a Sentence -- Freecod

    确保字符串的每个单词首字母都大写,其余部分小写。像'the'和'of'这样的连接符同理。当你完成不了挑战的时候,记...

  • Title Case a Sentence(FCC practi

    句中单词首字母大写确保字符串的每个单词首字母都大写,其余部分小写。像'the'和'of'这样的连接符同理。当你完成...

  • JS-Title Case a Sentence

    Title Case a Sentence确保字符串的每个单词首字母都大写,其余部分小写。 问题描述是不是有时候会...

  • FCC 题目 Title Case a Sentence

    要求 确保字符串的每个单词首字母都大写,其余部分小写。 像'the'和'of'这样的连接符同理。 当你完成不了挑战...

  • Title Case a Sentence | Free Cod

    确保字符串的每个单词首字母都大写,其余部分小写titleCase("I'm a little tea pot") ...

  • FCC-JS-BAS-Title Case a Sentence

    句中单词首字母大写确保字符串的每个单词首字母都大写,其余部分小写。像'the'和'of'这样的连接符同理。当你完成...

  • Design & Coed 3: 找出最长单词

    句中单词首字母大写 Title Case a Sentence 确保字符串的每个单词首字母都大写,其余部分小写。 ...

  • 2017-12-21作文

    TITLE:College is not an ivory tower 【Title sentence】Colle...

网友评论

      本文标题:Title Case a Sentence

      本文链接:https://www.haomeiwen.com/subject/qnyxnttx.html