mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-25 18:02:11 -05:00
634 B
634 B
title, localeTitle
| title | localeTitle |
|---|---|
| Remove Items Using splice() | Remover itens usando splice () |
Remover itens usando splice ()
- A função
splice()deve ser chamada na matrizarrpara remover 1 ou mais elementos do centro da matriz. - A matriz
arratualmente acrescenta-se ao valor de 16. Basta remover tantas variáveis neccessary para retornar 10.
Solução:
function sumOfTen(arr) {
// change code below this line
arr.splice(1,2);
// change code above this line
return arr.reduce((a, b) => a + b);
}
// do not change code below this line
console.log(sumOfTen([2, 5, 1, 5, 2, 1]));