Functional Programming to Convert Strings to URL | global variable change

Hi. Im doing this assigment and my solution seems to be working, however it doesn’t pass The globalTitle variable should not change test :cry:

My code:

// the global variable
var globalTitle = " Winter Is Coming";

// Add your code below this line
function urlSlug(title) {
  let tempTitle = title;
  let newArr = tempTitle.split(" ").filter( (a) => a!='').map((a) => a.toLowerCase());
  let newStr = newArr.join('-');
  return newStr;
// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"

I used console for debugging but the string seem the be same? What my code cannot pass this test?

You have changed it from what it was in the starting code, The issue is just that

1 Like