js array.length called from variable doesn't work, why?
<p>Here is code that I have copied from w3schools, I have different code, but the problem that I am having still happens in this simplified coding.</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

&lt;p id="demo"&gt;Click the button to create an array, then display it's length&lt;/p&gt;

&lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt;

&lt;script&gt;
function myFunction()
{
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var foods = ["steak","pizza","bread","fruits"];
var x=document.getElementById("demo");
var y=foods[3];
x.innerHTML= y.length;
}
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>When I do <code>x.innerHTML= fruits.length;</code>, I get <code>4</code> back which is what I want to get.</p>

<p>But when I call </p>

<pre><code>var y=foods[3];
x.innerHTML= y.length;
</code></pre>

<p>I get <code>6</code> which is the length of the word <code>"fruits"</code> but I want the length of the array <code>fruits</code>.</p>

<p>How do I do this?</p>

<p>I'm using jQuery, don't know if that affects anything. Do I have to add parenthesis or brackets somewhere?</p>
