In the code below all I'm trying to do at the moment is split the time variables (time11 and time12) into the hour and minutes value and push those values into an array (array1 for time11 hours & minutes and array 2 for time12 hours & minutes). The problem I'm having is when I print the arrays to the console they are displayed as [["17", "50"]] and [["04", "34"]] where I'd ideally like them to printed like ["17", "50"] & ["04", "34"]. Does anyone know why it's producing 2 sets of square brackets and how to get rid of the outer set. All help is appreciated.
Thanks
var time11 = "17:50";
var time12 = "04:34";
array1 = [];
array2 = [];
var timeDifference = function(time1, time2){
array1.push(time1.split(/[^\d]/));
array2.push(time2.split(/[^\d]/));
console.log(array1);
console.log(array2);
};
timeDifference(time11, time12);
splitreturns an array, and then you put that into thearray1/array2arrays? What else would you expect?timeDifferencetwice with some values.array1 = time1.split(/[^\d]/)';