Convert a select few HTML Entities

Tell us what’s happening:
one of those coding exercises
Intermediate Algorithm Scripting: Convert HTML Entities

Your code so far


function convertHTML(str) {
  const map = new Map();
    map.set('&', '&​amp;')
    map.set('<','&​lt;')
    map.set('>','&gt;')
    map.set('\"','&​quot;')
    map.set('\'', '&​apos;')
  return str.split('')
            .map( (char) => map.has(char) ? map.get(char) : char)
            .join('')
}

console.log(convertHTML("Schindler's List"));

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities

:thinking: You has copied not visible chars. Try replace it in your code. Avoid copy and paste.

1 Like