7 kyu

Capitalize first letter of a string

1,198 of 1,224donaldsebleung

Description:

Capitalize First Letter of a String

Write a function capitalize() which capitalizes the first letter (if any) of the given string. For example:

Input Output
string String
hello World Hello World
i love codewars I love codewars
This sentence is already capitalized This sentence is already capitalized
0123the first character of this sentence is not a letter 0123the first character of this sentence is not a letter

JavaScript / CoffeeScript: Extend the String prototype with a method capitalize() so you can call it on a string like so: "string".capitalize(). Learn about inheritance and the prototype chain.

Furthermore, the built-in string methods toUpperCase() and toLowerCase() are disabled for this Kata.

Fundamentals
Object-oriented Programming
Regular Expressions

Stats:

CreatedFeb 15, 2016
PublishedFeb 15, 2016
Warriors Trained3527
Total Skips59
Total Code Submissions8403
Total Times Completed1224
JavaScript Completions1198
CoffeeScript Completions11
RISC-V Completions26
Total Stars54
% of votes with a positive feedback rating83% of 256
Total "Very Satisfied" Votes193
Total "Somewhat Satisfied" Votes41
Total "Not Satisfied" Votes22
Ad
Contributors
  • donaldsebleung Avatar
  • Javatlacati Avatar
  • matt c Avatar
  • farhanaditya Avatar
Ad