Using indexOf() in Switch Statement : <p>Need to set variable values using a Switch Statement based on a string being present in the URL. I've accomplished this by using if/then statements but I now need a "default" for var3. It would be cumbersome to write a final if/then statement that basically says that the final condition is met when none of the other strings are found in dom.url. </p>

<p>Preferably, I'd want something like this: </p>

<pre><code>if b.event_name ==="form_completion" {
    switch(b['dom.url'].indexOf(MYSTRING)) {
        case "Req-Quote-Thanks-Modal") &gt; -1:
            b.var1 = "VAL1";
            b.var2 = "VAL2";
            b.var3 = "VAL3";
        break;
        deafult:
            b.var1 = "VAL1-Default";
            b.var2 = "VAL2-Default"; 
            b.var3 = "VAL3-Default"; 
        }
}
</code></pre>

<p>I've tired a series of if/then statements and case statements with if/then statements</p>

<pre><code>if (b.event_name === "form_completion" &amp;&amp; b['dom.url'].indexOf("Req-Quote-Thanks-Modal") &gt; -1) 
    {
        b.var1 = "VAL1";
        b.var2 = "VAL2";
        b.var3 = "VAL3";
    }
else if (b.event_name === "form_completion" &amp;&amp; b['dom.pathname'].indexOf("sweeps-thank-you") &gt;-1)
    {
        b.var1 = "VAL1";
        b.var2 = "VAL2";
        b.var3 = "VAL4";
    }
else if (b.event_name === "form_completion" &amp;&amp; b['dom.pathname'].indexOf("special-offers-thank-you") &gt;-1)
    {
        b.var1 = "VAL1";
        b.var2 = "VAL2";
        b.var3 = "VAL5";
    }
else if (b.event_name === "form_completion" &amp;&amp; b['dom.pathname'].indexOf("brochure") &gt;-1 &amp;&amp; b['dom.pathname'].indexOf("thank-you") &gt;-1)
    {
        b.var1 = "VAL1";
        b.var2 = "VAL2";
        b.var3 = "VAL6";
    }
</code></pre>
