To get last element in array in JavaScript, do this:
array[array.length - 1]
.Here's how you do it:
const array = [ 100, 42, 99 ];
const last = array[array.length - 1];
console.log(last); // 99
array[array.length - 1]
.Here's how you do it:
const array = [ 100, 42, 99 ];
const last = array[array.length - 1];
console.log(last); // 99