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
  • 45,440
  • 9
  • 78
  • 110
maaz
  • 3,534
  • 19
  • 61
  • 100

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,221
  • 10
  • 17