Tell us what’s happening:
i have no idea ow to use str.replace();
not sure i understand the documentation on how to use a function as the thing to be replaced with.
and i’m not sure how to make a “dictionary” of keys to reference what to be replaced with. (switch statement? object? array with .map() ?)
in short , absolutely lost
ignore my code, its my 127th try, and absolutely useless.
mostly what i want to know is how to use string.replace(); since thats what this exercise seems to be about.
Your code so far
function convertHTML(str) {
// :)
var Regcheck = /\W\s/gi;
var htmlListObj = {'&':"&",
"<":"<",
">":">",
"'":""",
'"':"'"};
/* var a = str.split(" ");
for(var i = 0;i<a.length;i++){
if(a[i] === Regcheck )
}*/
var b = "";
for(var i = 0;i<str.length;i++){
if(str[i].match(Regcheck) === htmlListObj[i]){
return str.replace(htmlListObj[key],htmlListObj[value]);
}
}
//return b;
}
convertHTML("Dolce & ^ $ Gabbana");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36
.
Link to the challenge: