Best way to upper case 2nd letter of string

I'm looking for the most elegant way to take a 4 letter string and make the 2nd letter uppercase while all other letters should be lower case.
Who is Participating?
smeghammerConnect With a Mentor Commented:
Try something like this:

function x(s)
s = s.toLowerCase();
s = s.substring(0,1)+s.charAt(1).toUpperCase()+s.substring(2,s.length);
//test the function:
x("abCD") ;

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.