0

I have a string

var str = "edit_country"

I want to split words based on underscore and make one string "Edit Country" Here first letter after space should be capital.

Amit
  • 43,881
  • 8
  • 73
  • 106
maaz
  • 3,190
  • 18
  • 55
  • 95

1 Answers1

1

You Should try this.

var str = "edit_country";
str=str.split('_');
alert(str[0].charAt(0).toUpperCase()+str[0].slice(1));
alert(str[1].charAt(0).toUpperCase()+str[1].slice(1));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
Ankit Kathiriya
  • 1,203
  • 10
  • 17