javascript function to replace all html entities code example
Example: Javascript convert html entity to string
const htmlEntities = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
};
return str.replace(/([&<>\"'])/g, match => htmlEntities[match]);
}