for example, now I have
player: {id: 1, name: "jack", selected_scenarios: "[369,368]"}
in the local storage.
within here [369,368]
is a javascript object with length of 7.
If I want to convert it into list of array, pull numbers out such that
electedArray = [369,368]
has length of 2, which can be read by electedArray[i]
0: 369
1: 368
how am I supposed to do so?
If I did
let test = res["player"]["selected_scenarios"];
let selectedArray = [];
for (var prop in test) {
selectedArray.push(test[prop])
}
console.log(selectedArray);
I got
["[", "3", "6", "9", ",", "3", "6", "8", "]"]
and split doesn't seem to work neither.
I know it looks like lots of similar questions around, but I still can't figure out how