Who can help to remove first space from string in code?)

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

// Add your code below this line
function urlSlug(title) {
  let arr1 = title.toLowerCase().split(/\W+/);
  let str = arr1.join("-");
  return str
// Add your code above this line

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

link : https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs

urlSlug(" Winter Is Coming") should return "winter-is-coming" .

Did you try the .trim() method yet?

don’t change this variable! the tests don’t make you pass

change the function call to try with different strings

try adding .trim() to the title


1 Like

Thank you for solution:slightly_smiling_face: