How to create an array from elements of another array using javascript
<p>I'm trying to filter an array to build another array with the results I get. But the combination of functions I have been using with jQuery haven't workk so far. So I would appreciate some advice about how to solve this.</p>

<p>Here is the example of what I'm trying to implement:</p>

<p>This is my first array:</p>

<pre><code>var data =[salt.1200, salt.1100, salt.1000, salt.0900, salt.0800, salt.0700, current.1200, current.1100, current.1000, current.0900, current.0800, current.0700];
</code></pre>

<p>And from this array I would like to build two different arrays, one for salt and one from current.</p>

<p>I have tried to use a for loop with a jQuery grep function on it and split, but that didn't worked.</p>

<pre><code>var plotsArray = [];
        for (var i=0; i&lt;data.length; i++){
            plotsArray = jQuery.grep(data, function(a){
                return (a.split(".") == 'salt')
            });
        }
        console.log('plotsArray: '+plotsArray);
</code></pre>

<p>Also, I been trying to do is to read the first part of the string until the dot and then build an array base on that result. Using for example array filter, but I haven't figure it out how to read just until the dot.</p>

<p>I will appreciate any guidance on how to solve this.</p>

<p>Regards,</p>
