freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

Bonfire: Convert HTML Entities : doesn't convert apostrophe

Open anknits opened this issue 11 years ago • 4 comments

Challenge http://www.freecodecamp.com/challenges/bonfire-convert-html-entities has an issue. Please describe how to reproduce it, and include links to screenshots if possible. Here is what my code looks like:

function convert(str) {
  // :)
  return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g,'&apos');
}

convert('Dolce & Gabbana');

However, it doesn't pass the test "Shindler's List". Why?

anknits avatar Sep 01 '15 10:09 anknits

The challenge itself doesn't have an issue. Please go the FreeCodeCamp Gitter help channel (https://gitter.im/FreeCodeCamp/Help) for help with the bonfire.

butterthebuddha avatar Sep 01 '15 10:09 butterthebuddha

@anknits To answer your immediate question, your apostrophe would not be replaced in the example code you've provided because the html entity ends in a semi-colon but your replace function for the apostrophe is missing this in the substitution.

Regarding the rest of your code, it is difficult to read the code you have pasted in because I believe the html entities you've typed in your replace functions have already been swapped out.

I, like @awesomeaniruddh do not believe there is an issue with this challenge.

catapixel avatar Sep 01 '15 18:09 catapixel

Well that explains the error. Thank you so much Jason.

Regards, Ankur On 2 Sep 2015 00:17, "Jason Wood" [email protected] wrote:

@anknits https://github.com/anknits To answer your immediate question, your apostrophe would not be replaced in the example code you've provided because the html entity ends in a semi-colon but your replace function for the apostrophe is missing this in the substitution.

Regarding the rest of your code, it is difficult to read the code you have pasted in because I believe the html entities you've typed in your replace functions have already been swapped out.

I, like @awesomeaniruddh https://github.com/awesomeaniruddh do not believe there is an issue with this challenge.

— Reply to this email directly or view it on GitHub https://github.com/FreeCodeCamp/FreeCodeCamp/issues/2950#issuecomment-136825212 .

anknits avatar Sep 01 '15 20:09 anknits

@anknits if your problem is solved feel free to close the issue, thanks.

bugron avatar Sep 01 '15 20:09 bugron