*This my version of the code I used a for loop to check all of the symbols and then replaced them.
function convertHTML(str) {
//
for(var i=0; i<str.length; i++)
{
switch(str[i])
{
case ‘&’:
str=str.replace(/&/i,’&’);
break;
case '<':
str=str.replace(/</i,'<');
break;
case '>':
str=str.replace(/>/i,'>');
break;
case '"':
str=str.replace(/"/i,'"');
break;
case "'":
str=str.replace(/'/i,''');
break;
}
}
return str;
}
convertHTML(‘Stuff in “quotation marks”’);
[/quote]
Literally the first time I felt like I came up with a good solution almost completely on my own and it was similar to the advanced meth I am happy with it, regex is starting to feel more comfortable
‘’’
function convertHTML(str) {
var re = /[&"’<>]/g;
var html = {
"&" : “&”,
""":""",
"<" : “<”,
">": “>”,
"’":"’"