How do I combine the two requested json files and work with their contents? How do I place their contents into a variable and work with them throughout the program? Assistance would be appreciated as I am stuck attempting to merge the two data files which are formatted like below. So if I wanted to combine the lapsLed key after names, raceWin, and number I would be able to without problems.
async function populate() {
const requestURL = 'nascar.json';
const request = new Request(requestURL);
const response = await fetch(request);
const nascarDrivers = await response.json();
findDriver(nascarDrivers);
return nascarDrivers;
}
async function texas() {
const requestURL = 'texasMS.json';
const request = new Request(requestURL);
const response = await fetch(request);
const texasLaps = await response.json();
findLaps(texasLaps);
return texasLaps;
}
{
"season" : 2022,
"sport" : "Nascar",
"drivers" : [
{
"name" : "Chase Elliot",
"raceWin" : "Low",
"number" : 9
},
{
"name" : "Kyle Larson",
"raceWin" : "High",
"number" : 5
},
{
"name" : "William Byron",
"raceWin" : "Medium",
"number" : 24
},
{
"name" : "Kevin Harvick",
"raceWin" : "Medium",
"number" : 4
},
{
"name" : "Kyle Bush",
"raceWin" : "Medium",
"number" : 18
},
{
"name" : "Kurt Bush",
"raceWin" : "Medium",
"number" : 45
}
]
{
"track" : "Texas",
"sport" : "Nascar",
"drivers" : [
{
"name" : "Chase Elliot",
"lapsLed" : 180
},
{
"name" : "Kyle Larson",
"lapsLed" : 72
},
{
"name" : "William Byron",
"lapsLed" : 0
},
{
"name" : "Kevin Harvick",
"lapsLed" : 55
},
{
"name" : "Kyle Bush",
"lapsLed": 33
},
{
"name" : "Kurt Bush",
"lapsLed" : 10
}
]
}