我有三个相互关联的数组(Users,Wins和Lost),Wins [0]到Wins [2]代表Users [0]到Users [2]。如果用户[0]到用户[2]获胜,用户[3]以及用户[4]失利,则丢失[3]和丢失[4]必须等于1。
var Users = ["user1", "user2", "user3", "user4", "user5"];
var Wins = ["1", "1", "1", "0", "0"];
var Lost = ["0", "0", "0", "0", "0"]; //Lost[3] and Lost[4] need to be equal to 1
最佳答案
您可以简单地使用map
和ternary operator
生成Lost
数组:
关于arrays - 将值分配给数组中的每个其他索引,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58261241/