Best practices - Arrays - arr.length saved as variable or used inline as index identifier?

Apologies if the terminology in the title in wrong. It should be made clearer below.

I’m immersing myself in anything and everything JS. Including the Codecademy course (of course), and others. One of these “others” is JS Hero. JS Hero is a beginner-level JS “course” with much less content and context behind each “lesson” than Codecademy offers.

One of the lessons is on Arrays. The exercise part of the lesson is to write a function that returns the last element of a given array. The site will check your solution against a series of tests. This feature I believe is similar to

The function I wrote (as an arrow function) is as follows:

getLastElement = arr => arr[arr.length - 1];

The exercises on JS Hero include the solution (hidden behind a toggleable part of the page). JS Hero’s solution to the exercise is to save arr.length - 1 to a new variable lastIndex, then use lastIndex as the index identifier, as so:

function getLastElement(anArray) {
  let lastIndex = anArray.length - 1;
  return anArray[lastIndex];

I know that both of the solutions essentially do the same thing, and I understand how/why.

My question is, of the two solutions, which is the better practice? Which is more elegant? Which is more readable?