LoginSignup
1
1

More than 3 years have passed since last update.

javascriptでアルファベットから数値へ変換する

Last updated at Posted at 2020-05-07

列のアルファベットを数値へ変換したいタイミングがあったので。

アルファベットから数値へ
// アルファベットを数値へ変換(順番に)
function convertToInt(a) {
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
return alphabet.indexOf(a) + 1 ;
}

2020年5月27日追記:コメントでいただいた記載の方がスマートに感じたので、配列→文字列へ変更

1
1
1

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
1
1