by having a return statemet, I assume this code is inside a function
if you put the return statement inside the for, it will exit returning the newDate value.
put the return outside the for statement, and push the dates in an array
function getDates()
{
dates = ['1-12-21 @ 12:31 AM', '1-26-21 @ 09:45 AM', '12-14-20 @ 2:22 PM']
var datesArray= new Array();
for(var i =0; i<dates.length;i++) {
var array = new Array();
array = dates[i].split('@');
var newDate = new Date(array[0] + " " + array[1]);
datesArray.push(newDate)
}
return datesArray;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…