Issue
[Edited because my question was not clear]
I would like to parse each string from an array into an object as its key with an assigned value e.x.:
There is an array called dates.
This is dates[0]
"2022-02-01"
And I would like to parse it in an object that looks like this:
let datesObj = { "2022-02-01": {selected: true, marked: true} }
I have looked into JSON.parse() but I have not been able to apply it to my needs in this case (if that is even the solution).
I haven't been able to find a suitable solution, so a big thank you to anyone willing to help.
Solution
Like this?
function parse(date)
{
const res = {}
res[date] = {
selected: true,
marked: true
}
return res;
}
Answered By - md2perpe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.