📜  骆驼案例优先 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:19.207000             🧑  作者: Mango

代码示例1
const country = 'united kingdom'

const countryArr = country.split(' ')
const newcountry = countryArr
    .map((val) => {
        const pattern = new RegExp(`^[${val}]`, 'i')
        return val.replace(pattern, `${val.charAt(0).toUpperCase()}`)
    })
    .join(' ')
    .trim()

console.log(newcountry)