Create an array of characters from specified range

后端 未结 12 2217
名媛妹妹
名媛妹妹 2020-12-17 08:19

I read some code where someone did this in Ruby:

puts (\'A\'..\'Z\').to_a.join(\',\')

output:

A,B,C,D,E,F,G,H,I,J,K,L,M,N,O         


        
12条回答
  •  Happy的楠姐
    2020-12-17 08:44

    var range = [];
    for(var i = 65; i < 91; i++)
    {
     range.push(String.fromCharCode(i));
    }
    range = range.join(',');
    

    gives range a-z, but i like the function option of some too.

提交回复
热议问题