I’m on the challenge “Find the Longest Word in a String”. I’m falling before the first hurdle though on the very basic issue of initialising my variable. In this case, just to check the working on the .split() method, I thought I’d try it out in isolation outside of any functions.
However, already on the second line of code, var arrayOfStrings = testString.split(" "); doesn’t recognise testString as existing (text stays white rather than going blue). I’m sure this is something really obvious and stupid, but I just can’t fathom why it won’t split and figure this sort of basic error will destroy pretty much any code I try to write.
Basically, how do I properly initialise my “testString” so I can use it later?
Your code so far
var testString = "Test word";
var arrayOfStrings = testString.split(" ");
console.log(arrayOfStrings);
// Not even started on trying to solve the algorithm issue yet
function findLongestWord(str) {
}
findLongestWord("The quick brown fox jumped over the lazy dog");```
**Your browser information:**
Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0```.
**Link to the challenge:**
https://www.freecodecamp.org/challenges/find-the-longest-word-in-a-string