我正在制作一个程序,根据我在sm4sh中使用的6个字符,向我输出帮助另一个的大量好匹配的字符,帮助其他字符与不良匹配,例如,我使用Rosalina,她对马里奥很不好,但是对于Ganondorf这场比赛对我有利,我现在要做的就是数组中所有元素的总和来检查我6个字符的所有数组中的54个字符(不是目前有不平衡的阵列)。 感谢。
瓦特// Rosalina的
var rosalina_good_matches = ["Ganondorf","King Dedede","Little Mac","Jigglypuff","Duck Hunt","Bowser","Zelda","Dr Mario","Charizard","Donkey Kong","Mr Game and Watch","Robin","Wario","Ness","Palutena","Wii Fit Trainer","Peach","Mewtwo","Samus","Mega Man","ROB","Lucina","Pac-Man","Falco","Toon Link","Yoshi","Marth","Ike","Link","Villager","Kirby","Greninja","Roy","Diddy Kong","Shulk","Luigi","Fox","Lucario","Meta Knight","Olimar","Sonic","Corrin","Sheik"];
var rosalina_even_matches = ["Pit","Dark Pit","Lucas","Captain Falcon","Pikachu","Bayonetta","Cloud"];
var rosalina_bad_matches = ["Mario","Zero Suit Samus","Ryu"];
//Check the sum of 54 characters
for(var i = 0;i < rosalina_good_matches.length;i++){
console.log(rosalina_good_matches[i]);
}
答案 0 :(得分:0)
要获取所有数组元素的总和(在一个字符串中),您应该使用.join()
(检查https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)