Trying to transform a string from this format:
string = "John:31,Miranda:28"
To this format:
obj = { "John" => 31, "Miranda" => 28 }
I attempted to do the following:
const class = new Map();
array = string.split(",");
However, after splitting the string, I end up with something like this:
["John:31", "Miranda:28"]
I am unsure of how to convert this array into an object format (using ":" as an arrow). Is there a way to bypass using the array as an intermediary? Any suggestions would be greatly appreciated. Thank you!