Having trouble with the URL challenge

Hi all campers,

So I am having trouble with this challenge: Apply Functional Programming to Convert Strings to URL Slugs

So here’s what I am thinking:

function urlSlug(title) {
  let result = title.toLowerCase.trim().split(" ")
  for (let i = 0; i < result.length-1; i++){
  return result
console.log(urlSlug("Winter Is Coming"))

I did the following:

  1. All to lowercase and get rid of spaces
  2. Split the string into array of words
  3. I loop over every word in the array and concat every word with a - except for the last word
  4. I join them into a single string

However, the result I have is
[ 'winter', 'is', 'coming' ]

I am pretty confused, I know theres some minor mistakes as I’ve already look through the answer, but why is my result still an array of words instead of a single string?

Thank you in advance :smile:

Join does not mutate the array. You’ll need to capture the output of join.

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