标签:str slice 字母 OLE spl ice class uppercase func
function capitalize(string){ var words = string.split(‘ ‘); var i; for(i = 0; i < words.length; i ++){ words[i] = words[i].charAt(0).toUpperCase()+words[i].slice(1); } console.log(words); return words.join(‘ ‘); } var str = "I am is a student"; console.log(capitalize(str));
标签:str slice 字母 OLE spl ice class uppercase func
原文地址:https://www.cnblogs.com/wlzdf999/p/9395143.html