Search tutorials
Easy, but wait it turns out you need eggs aswell, so how would you add in the eggs to the array, without having to write out the whole array again.Simple use the push code this allows you to add to the end of an array so change your code to:
groceries=["carrots","sausages","beans"]
groceries[0]="bacon"
groceries.push("eggs")
//The push function allows you to add strings on to the end of an array
trace(groceries)
You check your wallet and you haven't enough money to buy the eggs so you gotta get rid of em, how would you do this, use the pop() function, this removes the last item from an array.
groceries=["carrots","sausages","beans"]
groceries[0]="bacon"
groceries.push("eggs")
groceries.pop()
trace(groceries)
| » Level Intermediate |
|
Added: 2004-10-03 Rating: 7 Votes: 19 |
| » Author |
| Cool |
| » Download |
| Download the files used in this tutorial. |
| Download (0 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!