Capitilise the first letter in JavaScript


SUBMITTED BY: YouKnowNothing

DATE: Jan. 11, 2016, 10:32 a.m.

FORMAT: JavaScript

SIZE: 240 Bytes

HITS: 8893

  1. //Capitilise first letter
  2. String.prototype.capitilise = function(){
  3. return this.substring(0, 1).toUpperCase()+this.substring(1, this.length);
  4. }
  5. //Example usage
  6. var name = "michael";
  7. console.log(name.capitilise()); //Returns Michael

comments powered by Disqus