Bonfire: Convert HTML Entities : doesn't convert apostrophe
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, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g,'&apos');
}
convert('Dolce & Gabbana');
However, it doesn't pass the test "Shindler's List". Why?
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.
@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.
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 if your problem is solved feel free to close the issue, thanks.