return these indexes in an array of length 2 – first 0 and then the current index. code example
Example 1: array index javascript show only first 2 elements
array.slice(0, n);
Example 2: Getting One Value from an Array of Items
//Getting One Value from an Array of Items or sum of array
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
var total = numbers.reduce(function(total, current) {
return total + current;
}, 0);
console.log(total);