You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let a = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2'];
let b = ['A', 'B', 'C', 'D'];
let i = 0;
let m = 0;
for (let index = 0; index < a.length; index++) {
if (index % 2 == 0 && b[i]) {
++m;
// 插入位置的为 奇数 插入数组元素对应的索引 + 1
// i 也可以换成 b.indexOf(b[i]) + 1
a.splice((2 * m - 1) + i + 1, 0, b[i]);
i++;
}
}
The text was updated successfully, but these errors were encountered:
let a = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2'];
let b = ['A', 'B', 'C', 'D'];
let i = 0;
let m = 0;
for (let index = 0; index < a.length; index++) {
if (index % 2 == 0 && b[i]) {
++m;
// 插入位置的为 奇数 插入数组元素对应的索引 + 1
// i 也可以换成 b.indexOf(b[i]) + 1
a.splice((2 * m - 1) + i + 1, 0, b[i]);
i++;
}
}
The text was updated successfully, but these errors were encountered: