Assigning a new value to an index

You can also assign a new value to an index. Type and run the following code:

// Assign a new value, "Soy Milk" to index 2
shoppingList[2] = "Soy Milk"
shoppingList

ShoppingList now consists of "Eggs", "Chicken", "Soy Milk", and "Cooking Oil", and you can see this in the Results area.

Note that the index used must be valid.

Now, let's learn how to remove items from arrays.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.46.130