I have an array like:
["a", "b", "c", "d", "e"]
Now I want to just have the first 3 items. How would I remove the last two dynamically so that I could also have a 20 letter array, but reduce that down to the first 3 as well.
I have an array like:
["a", "b", "c", "d", "e"]
Now I want to just have the first 3 items. How would I remove the last two dynamically so that I could also have a 20 letter array, but reduce that down to the first 3 as well.
The splice function seems to be what you're after. You could do something like:
myArray.splice(3);
This will remove all items after the third one.