Arrays for Beginners

  • 220 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.capx

animals-starter.capx

Download now 173.28 KB
.capx

animals-complete.capx

Download now 174.16 KB
.capx

highscores-example.capx

Download now 182.31 KB

Contributors

Stats

29,471 visits, 107,150 views

Tools

Manipulating the array

You've seen how to change the values in the array. We can also manipulate the elements that make up the array by inserting and deleting elements and by rearranging them.

[5] Let's use the Insert action to add a new element with the value "cow" before the "mouse".

You can see that inserting a new element has increased the Width of the array to 6.

[6] Let's make the elephant disappear:

Magic!:

[7] Pushing inserts a new element at the front or back of the array. We can push a "tiger" onto the front of the array:

[8] Popping removes an element from the front or back of the array. We can pop the dog from the back of the array:

[9] Finally, we can sort the array - numerically or in alphabetical order:

[10] And we can reverse the order:

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!