Arrays
Arrays are a lists. They can be used however you want. To list all the numbers you push on a list. Answers to a flash based quiz, etc. So how to use them that's easy!
To make an array you need to set it up:
myArray = newArray();
There simple you now have an array called myArray (note you can call this whatever you want).
Now to add to your array there are many ways to do this, buttons, etc. Even when you set up the array!
myArray = new Array("element1", "element2");//where element1 and element2 are whatever you want in your array.
myArray.push("element1");//adds element1 to your array
myList = "element1, element2, element3";
myArray = myList.split(",");//separates each element then adds them to the array
Now we can add things how about we take some away.
myArray.shift();//removes the first element in your array
myArray.pop();//removes the last element in your array
myArray.splice("element1",1);//removes one element1
Ok if you like to be organised or need to organise the array it's as simple as having:
myArray.sort();
Now it's best to use these with buttons, etc so that you can easily add to or remove from the array instead of it continually doing it. Also having tracing the array works well to see what is in the array.
To make an array you need to set it up:
myArray = newArray();
There simple you now have an array called myArray (note you can call this whatever you want).
Now to add to your array there are many ways to do this, buttons, etc. Even when you set up the array!
myArray = new Array("element1", "element2");//where element1 and element2 are whatever you want in your array.
myArray.push("element1");//adds element1 to your array
myList = "element1, element2, element3";
myArray = myList.split(",");//separates each element then adds them to the array
Now we can add things how about we take some away.
myArray.shift();//removes the first element in your array
myArray.pop();//removes the last element in your array
myArray.splice("element1",1);//removes one element1
Ok if you like to be organised or need to organise the array it's as simple as having:
myArray.sort();
Now it's best to use these with buttons, etc so that you can easily add to or remove from the array instead of it continually doing it. Also having tracing the array works well to see what is in the array.