road = ['01', '04', '05', '02']
请问我想输出
new_road=[['01', '04'], ['04', '05'], [ '05', '02']]
请问应该怎么办?
road = ['01', '04', '05', '02']
请问我想输出
new_road=[['01', '04'], ['04', '05'], [ '05', '02']]
请问应该怎么办?
var oldArr = ['01', '04', '05', '02'];
var newArr = [];
for (i=0;i<oldArr.length;i++) {
if (i < oldArr.length-1) newArr[i] = [oldArr[i], oldArr[i+1]]
}