JS Cannot read property "length" of undefined : <p>I'm trying to create an object using a given string where each word has a property stating its length. </p>

<pre><code>var strings = {};

function findLongestWord(str) {
  var splitStr = str.split(" ");
    for (var i = 0; i &lt;= str.length; i++){
     strings[splitStr[i]] = splitStr[i].length;
  }

  return strings;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
</code></pre>

<p>I end up getting:</p>

<pre><code>"TypeError": Cannot read property "length" of undefined.
</code></pre>

<p>If I were to replace splitStr[i].length with splitStr[0].length, the code runs properly, but of course giving me the same number for each word in the object.</p>

<p>Any help is appreciated, thanks.</p>
