1// Define function to capitalize the first letter of a string
2function capitalizeFirstLetter(string){
3 return string.charAt(0).toUpperCase() + string.slice(1);
4}
5
6// Calling function and display the result
7var str1 = 'hi there!';
8str1 = capitalizeFirstLetter(str1);
9document.write(str1); // Print: Hi there!