const str = 'we_are_family'
const toUp = (tar) => {
let arr = tar.split('_')
let str = arr[0]
for(let i =1; i<arr.length; i++) {
str += arr[i].substring(0,1).toUpperCase() + arr[i].substring(1)
}
return str
}
const toUp1 = (tar) => {
let arr = tar.split('_')
let str = ''
arr.forEach((item, index) => {
if (index > 0) {
return str += item.replace(item[0], item[0].toUpperCase())
}
return str += item
})
return str
}
console.log(toUp(str))
console.log(toUp1(str))
const s = 'helloWorldOn'
const toline = (tar) => {
let fn = (item) => {
return '_'+ item.toLowerCase()
}
return s.replace((/[A-Z]/g), fn)
}
console.log(toline(s))
// console.log(str.substring(0,1))
// console.log(str.substring(1))
// console.log(str[0])
console