Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to capitalize first letter javascript

const names = ["alice", "bob", "charlie", "danielle"]
// -->        ["Alice", "Bob", "Charlie", "Danielle"]

//Just use some anonymous function and iterate through each of the elements in the array
//and take string as another array
let namescap = names.map((x)=>{
    return x[0].toUpperCase()+x.slice(1)
    
})
console.log(namescap)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #capitalize #letter #javascript
ADD COMMENT
Topic
Name
4+9 =