Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Greenheart opened this issue Feb 5, 2017 · 6 comments
Labels
first timers only Open for anyone doing contributions for first time. You do not need permission to work on these. help wanted Open for all. You do not need permission to work on these.

Comments

@Greenheart
Copy link
Member

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! 😄

@Greenheart Greenheart added first timers only Open for anyone doing contributions for first time. You do not need permission to work on these. help wanted Open for all. You do not need permission to work on these. labels Feb 5, 2017
@Quinn-H
Copy link
Contributor

Quinn-H commented Feb 5, 2017

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

@Greenheart
Copy link
Member Author

@Quinn-H Sure! 😄

@bigkatspence
Copy link

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

@Greenheart
Copy link
Member Author

@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! 😄

@Quinn-H
Copy link
Contributor

Quinn-H commented Feb 6, 2017

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"

@Greenheart
Copy link
Member Author

Greenheart commented Feb 6, 2017

@Quinn-H Thanks for helping out! 😄

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() 😊

// 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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first timers only Open for anyone doing contributions for first time. You do not need permission to work on these. help wanted Open for all. You do not need permission to work on these.
Projects
None yet
Development

No branches or pull requests

3 participants