I'm just kind of lousy with recursive functions.
I want to turn this...
const input = { regions: ["US", "CA", "LA"], checked: true };
...into the following, using recursion and reduce
:
const output = {
US: {
CA: {
LA: true
}
}
};
Help? I've tried lots of things, but my experiments are too embarrassing to share.