Tell us what’s happening:
Can someone please help me out as to why this code isn’t working it only works for strings with & but none of the other symbols. Greatly appreciate it any help
Your code so far
function convertHTML(str) {
// :)
var symbolPattern = /[&,<,>]/g;
var htmlString = "";
if(str.match(symbolPattern) == "&") {
htmlString = str.replace("&", "&");
} else if(str.match(symbolPattern) == "<") {
htmlString = str.replace("<", "<");
} else if (str.match(symbolPattern) == ">") {
htmlString = str.replace(">", "≯");
}
return htmlString;
}
convertHTML("Dolce & Gabbana");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/convert-html-entities