To create a dynamic array of strings with JavaScript, we just add or remove items as we want.
For instance, we write
const myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
myArray.push(11);
const popped = myArray.pop();
to call myArray.push
with 11 to push a 11 as the last item in myArray
.
And we call myArray.pop
to remove the last item in myArray
and return the removed item.