Javascript array-matching beginner
From a short review, considering you are a beginner;

keep your variables in lowerCamelCase so

COLORS -&gt; colors
CODES -&gt; codes


on the whole, avoid to have data type in the variable name

colorArray -&gt; colors


your commenting is quite good
Your indenting is inconsistent, it easier to read your code when code is properly indented
catchInvalid probably should return a boolean
I would have called catchInvalid -&gt; isInvalidColor it gives more detail
catchInvalid should either use the global, or know the colors locally
I would use COLORS.includes() over COLORS.indexOf
There is way to calculate the return code without making a distinction between 1 or 2 elements

Per the comment, a bit more explicit
    function decodeColorValues(colors){
      //These are all the possible colors
      const knownColors = [&quot;black&quot;, &quot;brown&quot;, &quot;red&quot;, &quot;orange&quot;, &quot;yellow&quot;, &quot;green&quot;, &quot;blue&quot;, &quot;violet&quot;, &quot;grey&quot;, &quot;white&quot;];        

      //Functions should return a consistent datatypes, so I return -1 instead of a message
      //If the caller did not provide an aray but say &quot;orange&quot;, then this will return -1 as well
      if(!colors.length){
        return -1;
      }
      
      //Filter out unknown colors
      colors = colors.filter(color =&gt; knownColors.includes(color));

      //If all colors were unknown then return -1
      //You could change this so that if 1 color is unknown it returns -1
      if(!colors.length){
        return -1;
      }      
      
      //We only deal with the first 2 entries (why?)
      colors = colors.slice(0,2);
      let value=0;
      
      //Abuse the fact that 10 times zero is still zero
      for(const color of colors){
        value = value * 10 + knownColors.indexOf(color);
      }
       
      return value;
    }


    console.log(decodeColorValues([&quot;blue&quot;]),
                decodeColorValues([&quot;nothing&quot;]),
                decodeColorValues([&quot;blue&quot;, &quot;green&quot;]),
                decodeColorValues([&quot;blue&quot;, &quot;nothing&quot;])
           );