slicer notation javascript
const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];
console.log(animals.slice(2)); //start from index 2
// expected output: Array ["camel", "duck", "elephant"]
console.log(animals.slice(2, 4)); //start from index 2 until index 4
// expected output: Array ["camel", "duck"]
console.log(animals.slice(1, 5)); //start from index 1 until index 5 (max index + 1 is acceptable)
// expected output: Array ["bison", "camel", "duck", "elephant"]
console.log(animals.slice(-2)); //start at the second last value
// expected output: Array ["duck", "elephant"]
console.log(animals.slice(2, -1)); //go from index to until the last value
// expected output: Array ["camel", "duck"]