const data = [
{ country: 'China', gold: 11, silver: 5, bronze: 8 },
{ country: 'Japan', gold: 11, silver: 4, bronze: 5 },
{ country: 'USA', gold: 10, silver: 11, bronze: 9 },
];
let res1 = { country: 'China', medal: 'gold', value: 11 };
let res2 = { country: 'China', medal: 'silver', value: 5 };
let res3 = { country: 'China', medal: 'bronze', value: 8 };
function change(data){
let res = [1,2];
data.map((item)=>{
if(item.gold){
res.push({
country:item.country,
medal:'gold',
value:item.gold
})
}
if(item.silver){
res.push({
country:item.country,
medal:'silver',
value:item.silver
})
}
if(item.bronze){
res.push({
country:item.country,
medal:'bronze',
value:item.bronze
})
}
})
res.forEach(item=>{
console.log(item);
})
}
change(data);
console