
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Return String by capitalizing first letter of each word and rest in lower case with JavaScript?
For this, use toUpperCase() along with toLowerCase(). Following is the code −
Example
function capitalEveryFirstletter(subjectTitle) { return subjectTitle.split(' ') .map(st => st.charAt(0).toUpperCase() + st.slice(1).toLowerCase()) .join(' ');; } var subjectTitle="iNtroduction tO JavaScript ProgRAMMINg"; var output=capitalEveryFirstletter(subjectTitle); console.log("The result="+output);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo74.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo74.js The result=Introduction To JavaScript Programming
- Related Articles
- Capitalizing first letter of each word JavaScript
- Print first letter of each word in a string in C#
- How to capitalize the first letter of each word in a string using JavaScript?
- Print first letter of each word in a string using C# regex
- Getting first letter of each word in a String using regex in Java
- Convert mixed case string to lower case in JavaScript
- Capitalize last letter and Lowercase first letter of a word in Java
- Python regex to find sequences of one upper case letter followed by lower case letters
- Java Program to Print first letter of each word using regex
- C++ Program to Print first letter of each word using regex
- Golang program to print first letter of each word using regex
- JavaScript Compare two sentences word by word and return if they are substring of each other
- Python program to capitalize each word's first letter
- How to get first letter of each word using regular expression in Java?
- Make first letter of a string uppercase in JavaScript?

Advertisements