Challenge Link: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs
I’ve completed the challenge alright;
But I think am using one too many lines for it. Am I wrong or Is there a shorter, simpler way of doing it?
My code:
function urlSlug(title) {
let newArray = title;
newArray = newArray.trim();
newArray = newArray.split(/\s+/);
newArray = newArray.join("-");
newArray = newArray.toLowerCase();
return newArray;
}