I have a block of code that saves the input into localStorage, however, when I look into localStorage it is not formatted properly. This is the code:
var selectN = document.getElementById("select").value;
var arr= JSON.parse(localStorage.getItem("Table"));
var arr2 = [arr]
arr2.push(selectN);
localStorage.setItem("Table", JSON.stringify(arr2));
However it ends up formatting like this:
[["", "Data1"], "Data2"]
which is not what I am looking for. I am looking for something like this ["", "Data1", "Data2"] However it seems that I am getting the same result. I have even tried:
const arr = [JSON.parse(localStorage.getItem('Data'))];
const arr2 = [
...arr,
selectN
]
Any help would be appreciated.
arrin another arrayarr2,var arr2 = [arr]this will add the value inside another dimension arrayvar arr2 = [arr]=> you put the array into an new array. is that how it should be?