JSFiddle - React, Tailwind, and code Playground

by HectorBarbossa

JavaScript

function changeToNum(val) {
    var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
        i, j, result = 0;

    for (i = 0, j = val.length - 1; i < val.length; i += 1, j -= 1) {
        result += Math.pow(base.length, j) * (base.indexOf(val[i]) + 1);
    }
    return result;
};


function changeToStr(number) {
    var baseChar = ("A").charCodeAt(0),
        letters = "";

    do {
        number -= 1;
        letters = String.fromCharCode(baseChar + (number % 26)) + letters;
        number = (number / 26) >> 0;
    } while (number > 0);

    return letters;
}

function findProp(obj, key, out) {
    var i,
        proto = Object.prototype,
        ts = proto.toString,
        hasOwn = proto.hasOwnProperty.bind(obj);

    if ('[object Array]' !== ts.call(out)) out = [];

    for (i in obj) {
        if (hasOwn(i)) {
            if (i === key) {
                out.push(changeToNum(obj[i]));
            } else if ('[object Array]' === ts.call(obj[i]) || '[object Object]' === ts.call(obj[i])) {
                findProp(obj[i], key, out);
            }
        }
    }

    return out;
}

var obj = {
    "features": [{
        "properties": {
            "name": "A",
            "description": null,
        },
        "type": "Feature"
    }, {
        "properties": {
            "name": "B",
            "description": null,
        },
        "type": "Feature"
    }, {
        "properties": {
            "name": "C",
            "description": null,
        },
        "type": "Feature"
    }],
    "type": "FeatureCollection"
};


var largest = Math.max.apply(Math, findProp(obj.features, "name"));

console.log(changeToStr(largest + 1));