How to make the first letter of a string uppercase in JavaScript? (without jQuery)
Hello everyone! I just started learning JavaScript and came across this task: I need to transform a string so that the first letter becomes uppercase, while the rest remain as is. For example, I have the string "hello world", and I want to get "Hello world".
I've tried several methods, but nothing works correctly. I tried using charAt() and toUpperCase(), but I only get a single uppercase letter, and the rest of the string is lost. Here's what I tried:
```javascript
let str = "hello world";
let firstChar = str.charAt(0).toUpperCase();
console.log(firstChar); // Outputs only "H"
```
How can I get the full string with the first letter capitalized? Do I need to use a loop or is there a simpler way? I've read that this can be done using slice() or substring(), but I'm not sure how.