JSFiddle - React, Tailwind, and code Playground
JavaScript
var x = ['a', 'b', 'c'];
var y = {};
var temp = y;
for (var i = 0; i < x.length; i++) {
temp[x[i]] = {};
temp = temp[x[i]];
}
console.log(JSON.stringify(y));
var x = ['a', 'b', 'c'];
var y = {};
var temp = y;
for (var i = 0; i < x.length; i++) {
temp[x[i]] = {};
temp = temp[x[i]];
}
console.log(JSON.stringify(y));