我正在编写一些代码,其中有两个变量,其中有几个不同的团队。我是 JS 新手,似乎无法理解如何在同一个 for 循环中打印两个变量的值。
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);
}
现在我知道上面的代码不会运行,我只是显示我想要打印到控制台的内容,我不知道如何添加在同一循环中引用away_team 的第二个元素。话虽如此,当我将 for 循环设置为
for (const element of home_team) {
console.log(element);
}
它可以毫无问题地打印我的主队列表,但我确实正在寻找一个可以打印我的主队和客队的循环,列表大小是相同的并且始终如此。
RISEBY
PIPIONE
相关分类