
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Make First Letter of a String Uppercase in JavaScript
To make first letter of a string uppercase, use toUpperCase() in JavaScript. With that, we will use charAt(0) since we need to only capitalize the 1st letter.
Example
function replaceWithTheCapitalLetter(values){ return values.charAt(0).toUpperCase() + values.slice(1); } var word="javascript" console.log(replaceWithTheCapitalLetter(word));
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo167.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo167.js Javascript
Advertisements