Tell us what’s happening:
Can’t understand why my code is not working. Everything seems ok in the console when I run it. Tried to do it in different ways, but keep getting the same issue:
http://take.ms/e3lhk
When looking for help I saw some people using map
, filter
or reduce
methods and seem to have no issues. I don’t want to simply copy it I don’t understand why it seems necessary to use those methods if my results on the console seem correct.
Any help plz?
Your code so far
// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
console.log(
title.trim()
.toLowerCase()
.split(/\W+/)
.join('-')
);
return
title.trim()
.toLowerCase()
.split(/\W+/)
.join('-');
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs/