How can i use Regular Expression with a variable in JavaScript?
<p>This code wants to check an array if the name is in it or not, and that the first letter of all the names in the array is uppercase. There are many users who write their name without using an uppercase letter in their first name.</p>

<p>So I want to pass this condition in the code, by Regular Expression ( /i ), I can use this with a string and some other functions, but I can't use it with a variable.</p>

<p>Can anybody help me?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function runTest() {
    "use strict";
    
    var value = document.getElementById("inin").value;
    
    if (names.indexOf(value) &gt; -1) {
        x.innerHTML = "yes " + value + " your name is here, your are fully approved";
    } else {
        x.innerHTML = "Sorry, Your name isn't here";
    }
}</code></pre>
</div>
</div>
</p>