xxxxxxxxxx
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
xxxxxxxxxx
var foods = ["kiwi","apple","banana"];
var banana = foods[foods.length - 1]; // Getting last element
xxxxxxxxxx
var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the array
xxxxxxxxxx
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
xxxxxxxxxx
var numbers = ["one", "two", "three"];
var lastnumber = numbers[numbers.length - 1];
console.log(lastnumber);
xxxxxxxxxx
let nums = [1,2,3,4,5];
let lastOne = nums.pop();
// -> lastOne = 5
// -> nums = [1,2,3,4];