Coding / Programming Videos

Post your favorite coding videos and share them with others!

JavaScript Capitalize First Letter: How to make strings and arrays sentence case

Download Video link >



JavaScript Capitalize First Letter: How to make strings and arrays sentence case

In this tutorial, you’ll learn how to use JavaScript to capitalize the first letter of a sentence or an array of words.

Don’t forget to subscribe to the Junior Developer Central channel for more videos and tutorials!

You’ll also learn some tips and tricks on how to make this simple bit of code more powerful within your applications.

Although this may seem like a simple task, using JavaScript to capitalize the first letter of a string or using JavaScript to capitalize first letter of each word of a string, it’s a common task for Junior Developers to do.

It will mainly come in to play when working with presented data to the user as you want to ensure a consistent experience for the user. For example, it might be that data was stored (possibly by the user themselves) in all upper or lowercase.

So, How do you capitalize the first letter in HTML?

The first thing you need to do is to get the first character of the string using either bracket notation [] or the charAt function. In the video, i’ll explain the difference between the two.

Once you have the first character you can make this uppercase with the toUpperCase function which will transform the character to uppercase.

The final thing you’ll need to do is get the rest of the remaining original string and add it to the first, uppercase letter. You can do this with the slice function which ill show in the video.

source

Bookmark(0)
 

 

View Comments source >

Transcript view all >

00:00 in this JavaScript snippet we're going

00:01 to look at how to capitalize the first

00:03 letter of a sentence or the first letter

00:05 of each word and the sentence of using

00:07 javascript hi this is James from junior

Leave a Reply

Please Login to comment
  Subscribe  
Notify of
Translate »