Array.prototype.atbeginnerconst colors = ['red', 'green', 'blue']
colors.at(0) // β 'red'
colors.at(1) // β 'green'Use at() to access an element by a positive index, just like bracket notation.
Array.prototype.at(index) returns the element at the given index. It works just like bracket notation for positive indices, but also accepts negative integers to count from the end.
Challenge: Implement getElement(arr, 0) that returns the first element of arr using .at(0).
getElement([10, 20, 30], 0) // β 10
getElement(['a', 'b'], 0) // β 'a'