Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

```js #419

Closed
Jerry-RL opened this issue Sep 8, 2020 · 0 comments
Closed

```js #419

Jerry-RL opened this issue Sep 8, 2020 · 0 comments

Comments

@Jerry-RL
Copy link

Jerry-RL commented Sep 8, 2020

const normalize = str => {
  const arr = str.split(/[\[\]]/).filter(Boolean);
  const createArr = arr => {
    return arr.reduce((obj, val, n, arr) => {
      arr.length > 1 ? (obj.children = createArr(arr.slice(1))) : "";
      obj.value = arr[0];
      return obj;
    }, {});
  };
  return createArr(arr);
};

Originally posted by @zengibm in #331 (comment)

@yygmind yygmind closed this as completed Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants