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

[ad_1]

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;
}

[ad_2]

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