Tell us what’s happening:
Hi, so I have been stuck on this problem and it seems I am not passing any of the tests except for the last one. However, upon doing a console log for each one, the code seems to work.
After checking the answer, my code looks very similar (I used apostrophes instead of quotation marks for the replacing the apostrophes). The weird thing is that the answer code passes and mine does not. Am I missing something silly that is causing my code to fail the tests? Thanks!
Your code so far
function convertHTML(str) {
// :)
str = str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');
// answer code
// str = str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'");
return str;
}
//convertHTML("Dolce & Gabbana");
//convertHTML("<>");
//convertHTML("Schindler's List");
//convertHTML('Stuff in "quotation marks"');
//convertHTML("Sixty > twelve");
convertHTML("Hamburgers < Pizza < Tacos");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities/