Array.prototype.lastIndexOfintermediateconst arr = [1, 2, 3, 2, 1]
arr.lastIndexOf(2, 2) // β 1 (search backwards from index 2)Pass a fromIndex to lastIndexOf() to limit how far back the backward search goes.
The optional second argument fromIndex tells lastIndexOf where to start searching backwards. Only positions β€ fromIndex are considered.
Challenge: Implement lastPosFrom(arr, val, from) that uses arr.lastIndexOf(val, from).
lastPosFrom([1, 2, 3, 2, 1], 2, 2) // β 1 (search up to index 2)
lastPosFrom([1, 2, 3, 2, 1], 2, 3) // β 3