JSFiddle - React, Tailwind, and code Playground

HTML

<button onclick="test();">Test It!</button>

JavaScript

function test(){
    var someobject={
        childOne:{
            grandchildOne:'Hello 1.1',
            grandchildTwo:'Hello 1.2',
            grandchildThree:'Hello 1.3',
        },
        childTwo:{
            grandchildOne:'Hello 2.1',
            grandchildTwo:'Hello 2.2',
            grandchildThree:'Hello 2.3',
        },
    };
    var child="childOne";
    var grandchild="grandchildTwo";
    try{
        alert('snippet one: '+someobject.child[grandchild]);
    }catch(e){
        alert('snippet one failed!');
    };
    try{
        alert('snippet two: '+someobject[child][grandchild]);
    }catch(e){
        alert('snippet two failed!');
    };
};