Tell us what’s happening:
My code appears to work for all test cases in Chrome’s console, but it won’t pass the test cases with quotation marks or apostrophes in the FCC console.
For example, when I use the Chrome console, convertHTML('Stuff in "quotation marks"')
returns Stuff in "quotation marks"
However, when I run the challenge through the FCC console, the same test case gives me an error: transformers.js:85 SyntaxError: unknown: Unexpected token, expected , (21:24)…
Can someone help me figure out what’s going on?
Your code so far
function convertHTML(str) {
// :)
var arr = str.split("");
var conv = {
"&":"&",
"<":"<",
">":">",
"'":"'",
'"':"""
};
for (let i = 0; i < arr.length; i++){
if(conv[arr[i]]){
arr[i]=conv[arr[i]];
}
}
return arr.join("");
}
convertHTML("Dolce & Gabbana");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) 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