Initialising string value?

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

I guess you didn’t? :thinking:

Thanks for the pointer, but surely that’s almost the opposite problem. Wouldn’t global vars be recognised in too many places if anything, not too few…?

That code works fine. What is the problem?

Huh weird. It doesn’t work for me. Thanks for checking. Could be a glitch, I guess.