Skip to content

Instantly share code, notes, and snippets.

@nosalvage
Last active January 3, 2017 15:22
Show Gist options
  • Save nosalvage/780e5dd1406520ee3db1026ea3e9417b to your computer and use it in GitHub Desktop.
Save nosalvage/780e5dd1406520ee3db1026ea3e9417b to your computer and use it in GitHub Desktop.
var positions = [
{
id: 0
},
{
id: 60
},
{
id: 120
}
];
var all_tr = []; //тут типа все трки
var new_data = []; //разбитые данные
for(var i = 0; i < positions.length ; i++){
if(i == positions.length){
for(var j = positions[i].id; j < all_tr.length; j++){
new_data[i].push(all_tr[j]); //добавить обьект в конец
}
}else{
for(var j = positions[i].id; j < positions[i++].id; j++){
new_data[i].push(all_tr[j]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment