0

So say I have an array and the user can add do it by a input html tag:

var example=["a","b"];
var command=document.getElementByID("id");

so idk how long the array will be when i execute the next step,which is selecting the last item in the array and register it in an object

example.split(",")
someObject[//how do i chose the last item?]
J.doe
  • 47
  • 1
  • 6

1 Answers1

1

You can select the last item in a javascript array like this

arr = example.split(",");
lastArr = arr[arr.length - 1];
KANAYO AUGUSTIN UG
  • 2,078
  • 3
  • 17
  • 31