JSFiddle - React, Tailwind, and code Playground

by joeycakes

JavaScript

console.log('^^^^^^^^^^');
var obj = {},
    name = 'hello-world-I-am-a-route';

function _route(arr,target){
    if(!target){target = obj;}
    if( arr.length >= 1 ){
        var key = arr.shift();
        _perpetuateSpace(target,key);
        
    } return target;
    var key = arr.shift();
    console.log(key);
    var space = arr.shift();
}

function _perpetuateSpace(target,space){
    if(!target[space]){
        target[space] = {};
    } return target[space];
}

console.log('Iterate through [' + name + ']');
_route( name.split('-') );
console.log('Result:')
console.log(obj);