I am trying to create a new array for each return of a for.
var route = [];
for (var i = 0; i < 5; i++) {
route[i].push(result.routes[0].overview_path[i].lat());
route[i].push(result.routes[0].overview_path[i].lng());
console.log(route[i]);
}
But the console tells me that it isundefined
You can't push to an undefined:
You are trying to access position i of an array that is not initialized. Initializing it solves the problem.