how to check next existance of a character in string in javascript
<p>Hi All I have a string like this</p>

<pre><code>var data='mobile,car,soap,room';
</code></pre>

<p>I am parsing from this string and making this string as comma sperated and pushing it into an array like this</p>

<pre><code>var availableTags=[];
var str='';
for(i=0;i&lt;data.length;i++)
{
 if(data[i]==',')
 {    
  availableTags .push(str);
  str='';
 }
 else
 {
   str +=data[i];
 }
}
</code></pre>

<p>But I am doing wrong as I cannot get the last value after comma... Now What I want to ask how can I come to know the next existance of <code>,</code> in my string that whether it exists or not. So that I can also include the last value.</p>

<p>I would also appreciate if someone guide me that how can I accomplish that same task some other way. 
I want the string to be an array and it should look like this</p>

<pre><code>  ["mobile","car","soap","room"]
</code></pre>
