所以我有这三个数组:
var a = ["one", "two", "three"];
var b = ["a", "b", "c"];
var c = ["1", "2", "3"];
我想像这样合并它们:
var d = [
["one", "a", "1"],
["two", "b", "2"],
["three", "c", "3"],
];
我该怎么做呢?我知道我需要一个foor循环,但是我似乎无法理解如何设置它。感谢您的任何答案!
喜欢:
const a = ['one', 'two', 'three'], b = ['a', 'b', 'c'], c = ['1', '2', '3'], combo = [];
for(let i=0,l=a.length; i<l; i++){
combo.push([a[i], b[i], c[i]]);
}
console.log(combo);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句