Is it possible to only map an array up to a certain index?
For example, say I have the following:
var nums = [1, 2, 3, 4, 5];
I want to sum up the numbers in the array, but only up to the 3rd index. Is it possible to pass in an argument to Array.map()
to only go up to a given index? Or is this only possible using a for
loop?