Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

Simple JavaScript function to capitalize first letter of a word

Posted on August 25, 2019August 4, 2020 by Habibie

Hi! Previously I was searching for a way to capitalize the first letter of a word in JavaScript. I thought there is built in function/method in JavaScript to do that, but I didn’t find it.

So, here is a simple function that I’ve made.

function capFirstLetter(txt){
	return txt.charAt(0).toUpperCase() + txt.slice(1)
}

To use this function, just call the function with any word as its parameter that you want to capitalize its first letter. For example:

capFirstLetter("hello")

Then it will return “Hello” instead of “hello”.

Post Views: 212
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
  • Advanced Blinking Marker Script to show objects position in your game canvas
  • Ciihuy Images Merger – Fast & Easy Online Image Combiner
© 2025 ThirteeNov | Powered by Superbs Personal Blog theme