Answers for "how to find the last index of array"

34

last index array javascript

var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
Posted by: Guest on July-25-2019
0

how to find last element of an array

let arry = [2, 4, 6, 8, 10, 12, 14, 16];
let lastElement = arry[arry.length - 1];

console.log(lastElement);
Posted by: Guest on December-20-2021

Code answers related to "how to find the last index of array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language