[Solved] JS Cannot read property “length” of undefined [closed]


you are looping over wrong array. you should use i < splitStr.length.

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

  return strings;
}

solved JS Cannot read property “length” of undefined [closed]