question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion to add an additional "Helpful Link" to the "Convert HTML Entities" challenge

See original GitHub issue

Challenge Convert HTML Entities.

Before I submit a PR, I’d like to get feedback on adding an additional link to reference on this challenge.

I might be wrong but I think this is the first exposure users have to regular expressions in the track so I think it would be helpful to also include a reference to .replace() which makes solving this challenge much more manageable for new coders.

Example solution:

function convert(str) {

  // The list of chars to convert
  var charHTMLlist = {
    "&" : "&",
    "<" : "&lt;",
    ">" : "&gt;",
    '"' : "&quot;",
    "'" : "&apos;"
  };

  // Char replacement function triggered when a match is found
  function charHTMLmapper(ch){
    return charHTMLlist[ch];
  }

  // Returns a new string with the encode matches
  return str.replace(/[&"'<>]/g, charHTMLmapper);

}

// returns "Dolce &​amp; Gabbana"
convert("Dolce & Gabbana");

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
erictleungcommented, May 6, 2016

@williamsolivera go for it! 👍 Please read the contributing guidelines if you haven’t already before taking care of the issue. And don’t hesitate to visit the Contributors Help if you have any questions about helping. They are pretty responsive and friendly!

0reactions
williamsoliveracommented, May 6, 2016

I’d love to do this change as my first contribution!

Read more comments on GitHub >

github_iconTop Results From Across the Web

convert HTML entities FreeCodeCamp challenge - YouTube
A character entity is a code used to represent a character that doesn't belong to the document's character set.
Read more >
freeCodeCamp Challenge Guide: Convert HTML Entities
You have to create a program that will convert HTML entities from string to their corresponding HTML entities. There are only a few...
Read more >
Solving "Convert HTML Entities" / freeCodeCamp Algorithm ...
Let's solve freeCodeCamp's intermediate algorithm scripting challenge, 'Convert HTML Entities'. Starter Code. function convertHTML(str) { return ...
Read more >
Convert HTML Entities - Medium
We need to convert the characters &, <, >, " (double quote), and ' (apostrophe), in a string to their corresponding HTML entities....
Read more >
How to decode HTML entities using jQuery? - Stack Overflow
These is the best way to decode HTML entities. All other answers (on this and similar questions) either use innerHTML (create new HTML...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found