Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8532787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:47:43+00:00 2026-06-11T09:47:43+00:00

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,P,Q,R,S,T,U,V,W,X,Y,Z

  • 0

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,P,Q,R,S,T,U,V,W,X,Y,Z

Is there something in Javascript that will allow this to be done just as easy? if not, is there Node module that allows for something similar?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:47:44+00:00Added an answer on June 11, 2026 at 9:47 am

    Javascript doesn’t have that functionality natively. Below you find some examples of how it could be solved:

    Normal function, any characters from the base plane (no checking for surrogate pairs)

    function range(start,stop) {
      var result=[];
      for (var idx=start.charCodeAt(0),end=stop.charCodeAt(0); idx <=end; ++idx){
        result.push(String.fromCharCode(idx));
      }
      return result;
    };
    
    range('A','Z').join();
    

    The same as above, but as a function added to the array prototype, and therefore available to all arrays:

    Array.prototype.add_range = function(start,stop) {
      for (var idx=start.charCodeAt(0),end=stop.charCodeAt(0); idx <=end; ++idx){
        this.push(String.fromCharCode(idx));
      }
      return this;
    };
    
    [].add_range('A','Z').join();
    

    A range from preselected characters. Is faster than the functions above, and let you use alphanum_range('A','z') to mean A-Z and a-z:

    var alphanum_range = (function() {
      var data = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.split('');
      return function (start,stop) {
        start = data.indexOf(start);
        stop = data.indexOf(stop);
        return (!~start || !~stop) ? null : data.slice(start,stop+1);
      };
    })();
    
    alphanum_range('A','Z').join();
    

    Or any character from the ascii range. By using a cached array, it is faster than the functions that build the array every time.

    var ascii_range = (function() {
      var data = [];
      while (data.length < 128) data.push(String.fromCharCode(data.length));
      return function (start,stop) {
        start = start.charCodeAt(0);
        stop = stop.charCodeAt(0);
        return (start < 0 || start > 127 || stop < 0 || stop > 127) ? null : data.slice(start,stop+1);
      };
    })();
    
    ascii_range('A','Z').join();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read some code that people use something like this view.setOnLongClickListener(null); What does
I have some code to read from a pdf file. Is there a way
When reviewing code I came across something odd, someone had read that you can
I am trying to read some XML code from a website, and am having
When my application first runs I'm using some simple code to read in some
I read some XSLT examples and found that code: <xsl:apply-template select=@*|node()/> What does that
I wrote some code to read a file in my Java Servlet class. (I'm
I have been trying to write some code in Scala to read a file
I've recently written a piece of code to read some data from a file,
I am trying to write some simple code which will read a text file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.