I am working on some code where I have two variables with several different teams in them. I am new to JS and can't seem to understand how to print the value of both variables in the same for loop.
let jsonData = pm.response.json();
let home_team = []
let away_team = []
let home_team_id = []
let away_team_id = []
//console.log(jsonData)
jsonData.games.forEach((b)=>{
home_team.push(b.home.name)
away_team.push(b.away.name)
})
pm.environment.set("Home_Team",home_team)
pm.environment.set("Away_Team",away_team)
//console.log(pm.environment.get("Home Team"))
//console.log(pm.environment.get("Away Team"))
for (const element of home_team) {
console.log(element + "VS" + away_team);
}
Now I know the code above will not run, I am just showing what I would like printed to console, I can't figure out how to add a second element that references away_team in the same looop. With that said when I set my for loop to
for (const element of home_team) {
console.log(element);
}
It prints my list of home teams with no issues but I really am looking for a loop that prints both my home and away team, the list sizes are the same and always will be.
Thanks in advance.
home_team? Strings or objects?