JSFiddle - React, Tailwind, and code Playground
by Alexander Branchugov
JavaScript
var data = getData();
var arr = [];
Object.entries(data).forEach(([key, value]) => {
if(key === 'PA') {
arr = arr.concat(value);
return;
}
value.forEach((item, index) =>
arr[index][key] = item.key.split(' - ')[0]
)
});
localStorage.setItem('arr', JSON.stringify(arr));
function getData() {
return {
"PA": [
{
"key": "71100730075 - 99010001",
"title": "71100730075 - 99010001"
},
{
"key": "711В0139001 - 99010001",
"title": "711В0139001 - 99010001"
},
{
"key": "711В0139003 - 99010001",
"title": "711В0139003 - 99010001"
},
{
"key": "711В0139008 - 99010001",
"title": "711В0139008 - 99010001"
},
{
"key": "711В0178001 - 99010001",
"title": "711В0178001 - 99010001"
},
{
"key": "711В0187001 - 99010001",
"title": "711В0187001 - 99010001"
},
{
"key": "711В0239001 - 99010001",
"title": "711В0239001 - 99010001"
},
{
"key": "711В1330001 - 99010001",
"title": "711В1330001 - 99010001"
},
{
"key": "711В3392001 - 99010001",
"title": "711В3392001 - 99010001"
},
{
"key": "711В5126001 - 99010001",
"title": "711В5126001 - 99010001"
},
{
"key": "711В5131001 - 99010001",
"title": "711В5131001 - 99010001"
},
{
"key": "711В5948001 - 99010001",
"title": "711В5948001 - 99010001"
},
{
"key": "711В6408001 - 99010001",
"title": "711В6408001 - 99010001"
},
{
"key": "711В9335001 - 99010001",
"title": "711В9335001 - 99010001"
},
{
"key": "711В9923001 - 99010001",
"title": "711В9923001 - 99010001"
},
{
"key": "711Г4580001 - 99010001",
"title": "711Г4580001 - 99010001"
},
{
"key": "711Г4870001 - 99010001",
"title": "711Г4870001 - 99010001"
},
{
"key": "711Г5351001 - 99010001",
"title": "711Г5351001 - 99010001"
},
{
...