passing an array from EJS to Javascript
<p>I am trying to passe an array from ejs to JavaScript. I can get to the values inside ejs but not from JavaScript. all the time i get undefined because the contents of the variable "test" is a string is not an array.</p>

<pre><code>&lt;script&gt;

var test = '&lt;%- level_tab %&gt;';
alert(test);

function level(s1,s2){
            var s1 = document.getElementById(s1);
            var s2 = document.getElementById(s2);
            s2.innerHTML = "";
            if(s1.value == "level_0"){
                var optionArray = test;
            }
            else if(s1.value == "level_1"){
                var optionArray = ["test|test01", "test0|test02"];
            }
 for(var option in optionArray){
                var pair = optionArray[option].split("|");
                var newOption = document.createElement("option");
                newOption.value = pair[0];
                newOption.innerHTML = pair[1];
                s2.options.add(newOption);
            }
        }
&lt;/script&gt;
</code></pre>