Automated nested objects
<p>A couple of days ago I was having fun with some js, when I came to the question if I could automate object nesting. Of course I'm still a newby so I haven't gotten too far.</p>

<p>But what I got is this:</p>

<pre><code>var a = {};
var stso = ""; storing the second object

function sto(b) { // start the object
    a[b] = {};
    stso = b;
}

function nmo(...objs) { // nesting more object
    console.log(objs[0]);
    if(objs.length) { // checking to see that I have at least one variable before proceding
        for(i = 0; i &lt; objs.length; i++) { // looping through arguments
            a[stso][objs[i]] = {}; // and now I would have to repeat one more more for lever for every argument, meaning, the deeper I want to go into the object, the more nested for loops I have to make.
        }
    }
}

sto("b");
nmo("c");
a.b.c = "Happy ending!";

console.log(a.b.c); // It seems we still dont have a happy ending

// and as a second example

sto("b");
nmo("c", "d", "e", "f", "g");
a.b.c.d.e.f.g = "Another happy ending!";

console.log(a.b.c.d.e.f.g); // Our second happy ending was also unhappy...
</code></pre>

<p>In summary, you define the second object in one function, you define as many objects as you want in your second function in order.</p>

<p>How could I achieve this with my current structure?</p>