String.prototype.slicebeginnerconst str = 'Hello, World!'
str.slice(7, 12) // β 'World'
str.slice(-6, -1) // β 'World'
str.slice(7) // β 'World!'Use slice() to extract a portion of a string by start and end indices, supporting negative indices.
A negative end counts from the end. str.slice(0, -1) drops the last character.
Challenge: Implement dropLast(str) that removes the last character.
dropLast('hello') // β 'hell'
dropLast('ab') // β 'a'