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++){
result[i].concat("-")
}
result.join("")
return result
}
console.log(urlSlug("Winter Is Coming"))
I did the following:
- All to lowercase and get rid of spaces
- Split the string into array of words
- I loop over every word in the array and
concat
every word with a-
except for the last word - 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