I have five parsed session storage which i combine when i click save button, the problem is i can’t combine all if one of the parsed data is empty, it throws an error.
How to remove if one of them is empty? Is there any method that don’t need to check it one by one.
Here’s my code.
const d1 = JSON.parse(sessionStorage.getItem('data1'));
const d2 = JSON.parse(sessionStorage.getItem('data2'));
const d3 = JSON.parse(sessionStorage.getItem('data3'));
const d4 = JSON.parse(sessionStorage.getItem('data4'));
const d5 = JSON.parse(sessionStorage.getItem('data5'));
const ArrayConcatSession = [...d1, ...d2, ...d3, ...d4, ...d5];