Array length in JavaScript

The length of an array is found using the property length:

let arr = ['a', 'b', 'c']; console.log(arr.length) // shows 'c'

If you know the length of an array, you can get its last element:

let arr = [1, 2, 3]; console.log(arr[arr.length - 1]) // shows 3

Create an array with arbitrary elements. Display on the screen the number of elements in this array.

Create an array with arbitrary elements. Display the last element of this array.

enru