Answers for "get last index o f 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 get last element of an array in swifg

let myArray = ["Hello!", "World!"]
let capacity = myArray.count
let lastElement = myArray[capacity-1]
print(lastElement)
Posted by: Guest on October-26-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language