Is it possible to combine all session storage into one?
I have these three arrays which I pushing into storage because I will access them later.
The reason why I’m doing this is that the array I need is on a separated page. So I can’t combine the array before pushing it into storage.
Here’s what i have tried.
function FnOne() {
let arrayInFnOne = [
{
'id': 1,
'Choices': 'Cheeta'
},
{
'id': 2,
'Choices': 'Eagle'
},
{
'id': 3,
'Choices': 'Elephant'
},
{
'id': 4,
'Choices': 'Duck'
},
{
'id': 5,
'Choices': 'Deer'
}
]
let FNDataOne = sessionStorage.setItem('FNoneData', JSON.stringify(arrayInFnOne));
}
function FnTwo(){
let arrayInFnTwo = [
{
'id': 6,
'Choices': 'Eggplant'
},
{
'id': 7,
'Choices': 'Tomato'
},
{
'id': 8,
'Choices': 'Potato'
},
{
'id': 9,
'Choices': 'String beans'
},
{
'id': 10,
'Choices': 'Squash'
}
]
let FNDataTwo = sessionStorage.setItem('FNtwoData', JSON.stringify(arrayInFnTwo));
}
function FnThree(){
let arrayInFnThree = [
{
'id': 11,
'Choices': 'Paper'
},
{
'id': 12,
'Choices': 'Pencil'
},
{
'id': 13,
'Choices': 'Monitor'
},
{
'id': 14,
'Choices': 'Pentel Pen'
},
{
'id': 15,
'Choices': 'Wire'
}
]
let FNDataThree = sessionStorage.setItem('FNthreeData', JSON.stringify(arrayInFnThree));
}
document.querySelector('button').addEventListener('click', () => {
let finalData = sessionStorage.setItem('FinalDataAns', concat(FNDataOne,FNDataTwo,FNDataThree))
console.log(finalData);
})
<button>
Save
</button>