javascript how to make json from string?
I have string let str = ‘1,2,3,4,5,6,7,8,9,0’; I would like to make it as like this. { 1:2, 3:4, 5:6, 7:8, 9:0 } How can I do this ? Only using map function can not solve this. >Solution : We can use Array.reduce() to do it let str = ‘1,2,3,4,5,6,7,8,9,0’; let result = str.split(‘,’).reduce((a,v,i,arr) =>… Read More javascript how to make json from string?