Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create a function that converts the array to the following object
- // It has to support unlimited amount of dots in the string and it has to be only one function
- var arr = [
- 'customer.name',
- 'customer.age',
- 'customer.event.id',
- 'zz.yy.dd.aa',
- 'aa.yy.zz.dd.kk'
- ];
- var targetObject = {
- customer: {
- name: '',
- age: '',
- event: {
- id: ''
- }
- },
- zz: {
- yy: {
- dd: {
- aa: ''
- }
- }
- },
- aa: {
- yy: {
- zz: {
- dd: {
- kk: '',
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment