How to make letter numbering?

  • 0
    How to make letter numbering go through the cycle? A, B, C ... Z, AA, AB, AC, etc.

    In general, you need an analogue like in css, only through js.
    counter-increment: col; 
    content: counter(col, upper-alpha);
    JavaScript Atticus Paul, Jun 19, 2019

  • 1 Answers
  • 0
    methods: {
    createAlphaIndex(num) {
    const base = 26;
    let str = '';

    do {
    const mod = num % base;
    num = num / base | 0;
    str = (mod ? String.fromCharCode('A'.charCodeAt(0) + mod - 1) : (--num, 'Z')) + str;
    } while(num);

    return str;
    },
    },


    <div v-for="i in 1000">{{ createAlphaIndex(i) }}</div>


    https://jsfiddle.net/bh0cep84/
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!