猿问

js多个数组元素两两组合三三组合

vararr1=["a","b"];vararr2=["A","B"];vararr3=["1","2"];
想得到arr=["a_A","a_B","a_1","a_2","b_A","b_B","b_1","b_2","A_1","A_2","B_1","b_2"];
和arr=["a_A_1","a_A_2","a_B_1","a_B_2","b_A_1","b_A_2","b_B_1","b_B_2"];
请问怎么写?
慕斯709654
浏览 1772回答 2
2回答

慕仙森

varnewArr1=arr1.map((v,i)=>{returnarr1[i]+"_"+arr2[i];});varnewArr2=arr1.map((v,i)=>{returnarr1[i]+"_"+arr2[i]+"_"+arr3[i];});
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答