你好,我在JS新来的学生,我想用split
在output[2]
这样我就可以拿一个月的数量dd-mm-YYYY
并使用push
到new array
到EM保存新月的名字(str?)。JavaScript的使用拆分到新阵列阵列多维
例如:21/05
/1989年,月的新数组中的一个新的名字:May
var output = [
[ '0001', '0002', '0003', '0004' ],
[ 'Roman Alamsyah', 'Dika Sembiring', 'Winona', 'Bintang Senjaya' ],
[ '21/05/1989', '10/10/1992', '25/12/1965', '13/9/1994', '10/8/1994', '19/7/1994' ],
] ;
function mixarray(){
var months =[]; //probably wrong should just push to new array in output ?
//months.push([]);
//console.log(output[2].length);
for(var i = 0; i < output.length ;i ++){
// console.log(output[i]);
for(var j=0 ; j< output[i].length; j++){
months = output[i][j].split("/");
}
}
console.log(months);
}
mixarray(output);
我做了一些分,但不知何故我的大脑试图把EM后坠毁到新阵列并将其与月份名称(可能使用if-else
为month's name
吧?) 它可能会更好地推入new-array in output
,所以它会显示像这样以后与sorted
(以后我可以做排序):
Months:
August,Dec,July,May,Oct,Sept
我只需要知道这个月怎么能推到一个新的数组:
['May','Oct','Dec','Sept','August','July'];
从这个:
[ '21/05/1989', '10/10/1992', '25/12/1965', '13/9/1994', '10/8/1994', '19/7/1994' ]
当你使用'个月您将要覆盖在循环的每次迭代'months'的价值='。最终结果将是'months'与上一次迭代 – charlietfl
中的拆分相同,您希望创建一个新月数组或用月份替换output [2]的内容? – brk