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.
str.slice(start, end) extracts a substring from index start up to (not including) end.
Challenge: Implement getMiddle(str) that returns characters from index 2 to 5 (exclusive).
getMiddle('abcdefgh') // β 'cde'