> For the complete documentation index, see [llms.txt](https://eleven-fifty-academy.gitbook.io/javascript-152-objects-arrays/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eleven-fifty-academy.gitbook.io/javascript-152-objects-arrays/05-arrays/solutions/first-and-last/last-element.md).

# Last Element

## Completed Code

```javascript
var arr=[ 'We', 'love', 'learning', 'JavaScript!','It', 'is', 'a', 'fantastic', 'language' ];

last = function(array) {
    return array[array.length - 1];
};

console.log(last(arr));
```

## Explanation

The code for this challenge is very similar to the previous one, however there is one small change. Rather than using an **index**, we use the **length property** of the array. Length is NOT zero-based, in order to get the last element we have to subtract one to call the proper index. If we didn't subtract one, our output would be **undefined**. This array does not have an element with an index of six.
