Tell us what’s happening:
Hi, so I am trying to turn the string into an array (of words used in that sentence) so that I can have index references. I have used the coma as a separator, but the consoles (both browser and FCC) show that arr has only one element, which is the string as a whole at index 0. Not sure what went wrong here, help please. Thank you
Your code so far
function findLongestWordLength(str) {
let arr = str.split(",");
console.log(arr)
arr.sort(function(a,b){return a-b});
return arr[-1];
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36
.
Link to the challenge: