Convert Strings to URL Slugs - globalTitle value should not change

I got stuck on this exercise for a while. My code was passing all tests except the first one:

The globalTitle variable should not change.

I test my code in jsbin so I can easily see the value of console.log(), then I copy and paste all code into the FCC editor. After a lot of research and no solutions, I realized that I had hard-coded the globalTitle variable as "Winter is Coming" (2 spaces before “Coming”). If you run into this problem, be aware that you need to change the value of var globalTitle back to it’s original value var globalTitle = "Winter Is Coming";(1 space between each word).

I’m not sure if this could be considered a bug, or if I just need to work on my attention to detail. the FCC platform is great. I finished a 3 month bootcamp and I’m still learning from these challenges. Thank you for this amazing resource.

Although to a human, having extra spaces in a sentence doesn’t change the meaning, to a computer two strings with different spacing are completely different entities. Close attention to spacing, punctuation, spelling, capitalization, etc, will matter a great deal when you’re programming.

I completely agree. I struggle with typos every now and then. In this case, it was unclear why my solution wasn’t working. I was testing that specific case to make sure that globalTitle was not being reassigned within my code. I was not aware that the challenge only accepts the original value of globalTitle as a valid case for the challenge.

+1 for trial and error

I ran into the same issue. I worked around it by:

  1. copy the contents of function urlSlug
  2. press button Reset All Code
  3. paste in the copied contents in function urlSlug
  4. Run tests again (all tests passed now)

I ran into the same problem, the globalTitle is not actually mutated, it’s a bug in FCC, while I was testing the code for other tests I was changing the global variables to suit those tests. After a while I discovered that they actually hard-coded the variable and they don’t want it changed! So you have to make sure: var globalTitle = “Winter Is Coming”;