What I have is an array like this: ['foo','bar'] and I want to turn it into an object that looks like this:
{
foo:{
bar:{
etc:{}
}
}
}
I’ve tried with two loops but I can get it to work if there is three values in the array.
Here’s the fiddle: http://jsfiddle.net/h67ts/
If you have to support IE < 9, you can either use a regular loop, or use this polyfill: