title: How do you pass a paramater in JS?
body: <p>I am confused on how parameters work since I'm quite new at this. I want to pass the variables <code>HEXformat</code> and <code>RGBformat</code> to <code>validatecolor</code>. The <code>validatecolor</code> is supposed to validate if the given variable is a valid HEX or RGB colour and is outputted as a boolean.</p>
  
  <p>My question is: How do I pass the <code>HEXformat</code> and <code>RGBformat</code> as a parameter to the <code>validateColor</code> function?</p>
  
  <pre><code>function onFormSubmitted(RGBformat, Hexformat){
    var colorvalue = document.getElementById('colorvalue').value;
  
    var RGB = document.getElementById("RGB").checked;
    var HEX = document.getElementById("HEX").checked;
  
    if (RGB == true) {
      var RGBformat = "rgba(" + colorvalue + ")";
      alert(RGBformat);
    } else if (HEX == true) {
      var HEXformat = "#" + colorvalue;
      alert(HEXformat);
    }
    return HEXformat, RGBformat;
  }
  
  window.validateColor = (color) =&gt; {
    let colorRegExp = new RegExp(/^#([\da-f]{3}){1,2}$|^#([\da-f]{4}){1,2}$|(rgb|hsl)a?\((\s*-?\d+%?\s*,){2}(\s*-?\d+%?\s*,?\s*\)?)(,\s*(0?\.\d+)?|1)?\)/igm);
  
    let matchResult = color.match(colorRegExp);
  
    let isValid = ((matchResult == null) ? false : true);
  
    // this function returns a &lt;boolean&gt; value (i.e. returns true when the specified color is valid and false when color is invalid)
    return isValid;
  }
  </code></pre>