Functional Programming - Apply Functional Programming to Convert Strings to URL Slugs

Tell us what’s happening:
Describe your issue in detail here.
not passing !!
Your code so far

// Only change code below this line
function urlSlug(title) {

  let upWords= title.split(" ");

  let loWords= upWords.reduce((lWords,uWords)=>{

    let lowercaseWord = uWords.toLowerCase();
    lWords.push(lowercaseWord);
    return lWords;
    
  },[])

  let joined= loWords.join("-");

  return joined


}
// Only change code above this line
console.log(urlSlug("Winter Is Coming"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

Challenge: Functional Programming - Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

you need to handle cases where multiple spaces are between the words, and when spaces are at he start/at the end of line, if log out upWords after

this line, you’ll see that for this case:
urlSlug(" Winter Is Coming")
you’ll get this array:
[ '', 'Winter', 'Is', '', 'Coming' ]
using join on this array won’t give the expected result

1 Like

Yeah later I saw that i needed to use trim method and space+ to remove that problem… so i copied… The code …

Thanks …

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.