Javascript flat list to array concatenation
<p>I am struggling with a particular Javascript problem and I hope someone can help.</p>

<p>I have a list of name and value pairs, e.g.:</p>

<p>Apple 50<br>
Banana 60<br>
Grape 70<br>
Apple 40<br>
Orange 30<br></p>

<p>I am trying to create a Javascript object out of these values:</p>

<pre><code>var myObj = {};
</code></pre>

<p>and then for all items in the list:</p>

<pre><code>myObj[name] = value;
</code></pre>

<p>but as you can see some names are in the list more than once (e.g. Apple), so in this case I would like to add it to the same property of the object by converting the value in the object to an array and adding the new value to the array.</p>

<p>So myObj would contain:</p>

<p>Apple = [50,40]<br>
Banana = 60<br>
Grape = 70<br>
Orange = 30<br></p>

<p>Anyone help?</p>

<p>Thanks,</p>

<p>AJ</p>
