Convert Camel Case in React
//////////First Method
const ConverCamelCase=(sentence)=>{
return sentence
.toLowerCase()
.replace(/[^a-zA-Z0-9 ]/g, '')
// Remove any non-alphanumeric characters
.split(' ')
.map((word, index) => index === 0 ?
word : word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
}
//////////// Second Method
const ConverCamelCase=(sentence)=>{
return sentence
.toLowerCase()
.replace(/[^a-zA-Z0-9 ]/g, '') // Remove any non-alphanumeric characters
.split(' ')
.map((word, index) =>
word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
}
Comments
Post a Comment