字符串数组,实现首字母大写,其他小写
请把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字。输入:['adam', 'LISA', 'barT']
,输出:['Adam', 'Lisa', 'Bart']
['adam', 'LISA', 'barT'].map((i)=> i.toLowerCase().replace(/^[a-z]/,j=>j.toUpperCase()) )
array.map(cbfn,arr)方法接收两个参数,第一个cbfn回调函数接收数组当前成员、当前位置和数组本身三个参数,第二个参数用来绑定cbfn里的this。
注意参数!!!!!!!!!!!!!!!
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/map