Functional Programming - Return Part of an Array Using the slice Method

Tell us what’s happening:
Describe your issue
Question kindly assist me to understand why slice (1,3) returns “Tiger” from the given array, yet Tiger is not index 3?
Thanks

Your code so far

const arr = ["Cat", "Dog", "Tiger", "Zebra"];
const newArray = arr.slice(1, 3);
newArray would have the value ["Dog", "Tiger"].

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36

Challenge: Functional Programming - Return Part of an Array Using the slice Method

Link to the challenge:

Meaning ends at 3 index but does not include that element, just tried to change 3 to 4 to understand better
noted thanks

const arr = ["Cat", "Dog", "Tiger", "Zebra"];
const newArray = arr.slice(1, 4);
console.log(newArray)
returns  ['Dog', 'Tiger', 'Zebra']

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.