"js array string patch name to array(object)" Code Answer

1

here's a non recursive way to get you most of the way there.

function compress(str) {
    var split = str.split('.'), obj = {}, current = obj, i;

    for (i = 0; i < split.length; i++){
        current[split[i]] =  {} ;
        current = current[split[i]];
    }

    return obj;
}
By arash moeen on September 27 2022

Answers related to “js array string patch name to array(object)”

Only authorized users can answer the Search term. Please sign in first, or register a free account.