Skip to main content
Obi-wan Kenobi
Legend
March 10, 2017
Answered

Increment an "alphabetic" counter!? …

  • March 10, 2017
  • 1 reply
  • 344 views

Hi Scripters,

I'm really perplexed with this!

        // ..................................

        var myCounter = 1;

        for ( .............. ) {

            // ..................................

            myCounter++

            }

How play with an "alphabetic" counter!

Here, my counter begins to "1", then jump to "2", then to "3" …!

… But I'm trying to get: "a", then "b", then "c", …!

So, perplexed! 

Thanks for help!

(^/)

This topic has been closed for replies.
Correct answer TᴀW

What happens when you get to 'z'?

If it's only A-Z, you could try:

String.fromCharCode(64+i)

... because 65 is the ASCII code for A.

But if you need something more complicated, say x,y,z,aa,bb,cc, etc., you'll have to build the function yourself...

1 reply

TᴀW
TᴀWCorrect answer
Legend
March 10, 2017

What happens when you get to 'z'?

If it's only A-Z, you could try:

String.fromCharCode(64+i)

... because 65 is the ASCII code for A.

But if you need something more complicated, say x,y,z,aa,bb,cc, etc., you'll have to build the function yourself...

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Obi-wan Kenobi
Legend
March 10, 2017

Thanks Ariel! I won't never jump after "z"!

Perfect with:

        var myCounter = String.fromCharCode(97);

… because 97 is the ASCII code for "a"! 

(^/)