Array.push Q

I have 4 buttons and an empty array. When a button is clicked,I’m adding a element to an array with array.push.

However, I want to check the array 1st to see if that element exists. If so, then don’t add it.

Here’s what I have thus far


completedElements = [];
num1.onPress = function() {
    completedElements.push("a")
    trace(completedElements.length);
    trace(completedElements);
};

Now I’m taking it I’d have a conditional statement to see if the element already exists. Unfortunatly I cannot just disable the button.

I searched the AS dictionary but oddly enough it doesn’t have an easy way to search an array.

And IndexOf seems to only work for a string.

Thanks :thumb: