Array.prototype.withintermediateconst arr = ['a', 'b', 'c']
arr.with(-1, 'z') // β ['a', 'b', 'z']
arr // β ['a', 'b', 'c'] (unchanged)Pass a negative index to with() to replace an element counting from the end.
with() supports negative indices. -1 refers to the last element.
Implement replaceFromEnd that replaces the last element of arr with val using arr.with(-1, val).