Tell us what’s happening:
My code passes all the tests except the “Schindler’s List” and ‘Stuff in “quotation marks”’ tests. What’s especially confusing me is that when I check the output against the asserted output, it matches, but the test is still failing.
Your code so far
function convertHTML(str) {
// :)
let chars = [/&/g, /</g, />/g, /\"/g, /\'/g];
let replacements = ['&', '<', '>', '"', '''];
for(let i = 0; i < 5; i++) {
str = str.replace(chars[i], replacements[i]);
}
console.log(str);
return str;
}
convertHTML("Dolce & Gabbana");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities