Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

684 B

title
title
Remove Items Using splice()

Remove Items Using splice()


Problem Explanation

  • The splice() function must be called on the arr array in order to remove 1 or more elements from the center of the array.
  • The array arr currently adds up to the value of 16. Simply remove as many variables neccessary to return 10.

Solutions

Solution 1 (Click to Show/Hide)
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]));