I have an object and I want to access this:
obj['example']['example-2']['example-3'];
problem is I have an array where I store those keys:
arr = ['example', 'example-2', 'example-3'];
but this array can be of variable length so maybe it's just 3 keys maybe there are 6. How can I achieve this without hardcoding each case, for example:
if(arr.length == 1){
//obj[arr[0]];
}else if (arr.length == 2){
//obj[arr[0]][arr[1]];
}
etc..