Freecodecamp: [beta] Unneccessary semicolon in "Functional Programming: Apply Functional Programming to Convert Strings to URL Slugs"

Created on 5 Feb 2017  ·  6Comments  ·  Source: freeCodeCamp/freeCodeCamp

Challenge apply-functional-programming-to-convert-strings-to-url-slugs has an issue.


// the global variable
var globalTitle = "Winter Is Coming";

// Add your code below this line
function urlSlug(title) {
  return title.trim()
          .split(' ')
          .map(word => word.toLowerCase())
          .join('-');
}; // <-- This triggers the linter
// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"

The editor's linter complains about an unnecessary semicolon - see the comment in the code above.

If you want to fix this, please read CONTRIBUTING.md to get started.

When you're all set, replace this line with the following, and make your commit.

"}",

If you have any questions, please come chat with us in the Contributors Chat Room.

Happy Coding! :smile:

first timers only help wanted

Most helpful comment

Hi, @Greenheart I deleted Unnecessary semicolon and created a pull request. Thank you. And I also found the answer you wrote for this challenge isn't right, you forgot filter() out extra space before join('-') see below:

// the global variable
var globalTitle = "Winter Is Coming";

// Add your code below this line
function urlSlug(title) {
  return title.trim()
          .split(' ')
          .map(word => word.toLowerCase())
          .filter(words => words !== '')
          .join('-');
} // <-- This triggers the linter
// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"

All 6 comments

Hi, @Greenheart. Can I work on it? It is my first time. Thank you

@Quinn-H Sure! :smile:

i would like to help a bit i am not the best but i am good at finding bugs let me know if i can help

@bigkatspence This issue is assigned to @Quinn-H, but if you want to help out, there's plenty of things that we really would appreciate:

  • Find issues you want to help fix, and submit pull requests for them. Refer to CONTRIBUTING.md for a guide on how to set up a local environment.
  • Read issues here on GitHub and respond with your thoughts to help find solutions to problems

Or, the most fun one: Help beta-test the new curriculum over at https://beta.freecodecamp.com and report any bugs you find here. This is a great way to learn new things while getting open source contributions.

Hope that helps! If you need anything, please come chat with us in /Contributors on Gitter.

Happy coding! :smile:

Hi, @Greenheart I deleted Unnecessary semicolon and created a pull request. Thank you. And I also found the answer you wrote for this challenge isn't right, you forgot filter() out extra space before join('-') see below:

// the global variable
var globalTitle = "Winter Is Coming";

// Add your code below this line
function urlSlug(title) {
  return title.trim()
          .split(' ')
          .map(word => word.toLowerCase())
          .filter(words => words !== '')
          .join('-');
} // <-- This triggers the linter
// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"

@Quinn-H Thanks for helping out! :smile:

I solved it by splitting on /\s+/ instead of jsut ' '. This way, it still splits by words but can handle extra spaces. I also made a copy of the string using slice() to not mutate the original when i use trim() :blush:

// the global variable
var globalTitle = "Winter Is Coming";

// Add your code below this line
function urlSlug(title) {
  return title.slice()
          .trim()
          .split(/\s+/)
          .map(word => word.toLowerCase())
          .join('-');
}
// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
Was this page helpful?
0 / 5 - 0 ratings

Related issues

raisedadead picture raisedadead  ·  3Comments

jurijuri picture jurijuri  ·  3Comments

vaibsharma picture vaibsharma  ·  3Comments

danielonodje picture danielonodje  ·  3Comments

kokushozero picture kokushozero  ·  3Comments