Update index.js

Fixed typo (lable)
Replaced shift loop with splice
Removed unused dependency (map is natively available on arrays)
Removed code which will never be used (array[array.length] will always be undefined)
YW ;)