0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node.js:文字列を区切って、各先頭を大文字にして、連結する。

Posted at
filename = "ada_sdl_dsl";
filename = convertName(filename);


//先頭を大文字にする。
function initialToUpper(str)
{
	return str.charAt(0).toUpperCase() + str.slice(1);
}

//アンダーバーを削除して、次の文字を大文字にする。
function convertName(str)
{
	var buf = "";
	var strlist = str.split('_');
	strlist.forEach( function(s) {
		console.log(s);
		buf += initialToUpper(s);
	})
	return buf;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?