1 Reply Latest reply on Nov 9, 2012 12:51 AM by baftos

    how to compare values in an array if they are the same or not

      Hi All,

      I know this is a Java forum, but since I need help in java script, I thought I should give this forum a shot.
      I have an array that contains the following values:

      array = {"Yes", null, null, "Yes"}
      my goal here is to check the elements to see if they match.

      array = {"Yes", null, null, "Yes"} - return "Yes"
      array = {"Yes", "Yes", "Yes", "Yes"} - return "Yes"
      array = {"Yes", "No", "Yes", "Yes"} - return "Rej" because they don't match
      array = {"No", "No", null, null} - return "No"
      array = {null, null, null, null} - return null

      Anytime the array has a different value other than null, then the return has to be "Rej"

      This is what i have so far. How can I do the comparison.

      Array_length = myArray.length;
      for (i = 0; i < Array_length; i++){
           for (j = i+1; j < Array_length; j++){
                if (myArray[i] == myArray[j]){
      Thanks in advance.

      Edited by: Rooney on Nov 8, 2012 2:13 PM