I have a multidimensional array like:
profile = [[2001-05-01, 20], [2001-05-02, 23], [2001-05-03, 18], ...];
I create a new array and manipulate the second element of the array by a variable factor.
I'm doing this right now and it works:
function new_ar(origin, start, end, factor) {
var result = [[]];
result = origin.slice(start, end).map(function(item){ return [item[0], parseInt(item[1])*factor]});
return result;
};
I get the desired array:
array2 = [[2001-05-01, 400], [2001-05-02, 460], [2001-05-02, 360], ...]
Problem
How can I get a new array3, which consists of the first n and last m elements of array2? I need to call a function like
function new_ar(origin, start1, end1, factor){
...code...
}
for example: I have an array with 200 elements, I need to get a new array with the first 100 and last 50. That means, that I need to say delete from 100 to 149.
Array.prototype.splice?slicevs.spliceI'm talking about developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…