Arrays Help?
- Started
- Last post
- 6 Responses
- fusionpixel
I have an array
array = [a,b][a,b];
I would like to delete one of the objects if they are the same, i tried
if (array[0] == array[1]){
//delete array
}but no workee. Anyone has any ideas suggestions?
- monNom0
since it's a 2d array I'm 90% sure your syntax is incorrect. try:
array = a,b],[c,d]];
and access it like so:
array[0][0]
(returns 'a')array[0][1]
(returns 'b')array[1][0]
(returns 'c')array[1][1]
(returns 'd')then use a for loop to check the values.
for (i=0; i
- fusionpixel0
cool! I think your for loop got truncated :(
- monNom0
opps, cut off.
use two nested for loops, one for array[0] the other for array [1]
with the increment set to the array index ( array[0][i]).then an if statement to compare, and .splice to remove.
- fusionpixel0
cheers, it makes sense.
Basiclly I need to pull the contents before comparignt and they have to come out individually.
Thanks!
- monNom0
I think there might actually be some sort of compare function built in.. but hell if I know how to use it.
- fusionpixel0
yeah, there is no compare function, I wish there were!