Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | export function sumArray(array: number[] | null): number { if (Array.isArray(array) && array.length > 0) { array.sort((a, b) => a - b); array.shift(); array.pop(); return array.reduce((acc, currentValue) => acc + currentValue, 0) } return 0; } console.log(sumArray([6, 2, 1, 8, 10]), 16); console.log(sumArray([6, 0, 1, 10, 10]), 17) console.log('slice(1, -1): [ 6, 0, 1, 10, 10 ]', [6, 0, 1, 10, 10].slice(1, -1)) |