A simple example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
the output of fruits.slice(0,-2) is ["Banana", "Orange"], which is the first two items in the list.
however, the output of fruits.slice(-2) is ["Apple", "Mango"] , which is the last two items in the list.
.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Can you elaborate on output = output.slice(0, -2)? Why would we want to remove the last 2 items?
A simple example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
the output of fruits.slice(0,-2) is ["Banana", "Orange"], which is the first two items in the list.
however, the output of fruits.slice(-2) is ["Apple", "Mango"] , which is the last two items in the list.
.