DEV Community

Discussion on: Deli Counter Challenge

Collapse
 
miaonanlin profile image
miaonanlin

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.
.