Q:

Write a JavaScript program to unescape escaped HTML characters

0

Write a JavaScript program to unescape escaped HTML characters.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const unescapeHTML = str =>
  str.replace(
    /&|<|>|'|"/g,
    tag =>
      ({
        '&': '&',
        '<': '<',
        '>': '>',
        ''': "'",
        '"': '"'
      }[tag] || tag)
  );
console.log(unescapeHTML('<a href="#">Me & you</a>'));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now