Return Part of an Array Using the slice Method (a little more explanation)

Return Part of an Array Using the slice Method (a little more explanation)
0.0 0

#1

Tell us what’s happening:

This might be a stupid question but why does this not work here? I know the correct answer to the problem, I just want a little more explanation =]. Tia

Your code so far


function sliceArray(anim, beginSlice, endSlice) {
  // Add your code below this line
  return this.slice(beginSlice, endSlice);
  
  // Add your code above this line
}
var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
sliceArray(inputAnim, 1, 3);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1 Safari/605.1.15.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method


#2

When a function is called (just a standard call, not something like obj.function()), the this keyword in the function will refer to the global object (the window object in browsers). By default the global object has no slice function, so it fails.