Convert HTML Entities: why is my solution Wrong?

I used the following solution:

function convertHTML(str) {
  var p = document.createElement("p");
  p.textContent = str;
  var converted = p.innerHTML;
  return converted;

convertHTML("Dolce & Gabbana");

No test cases are passed, i check in the console and everything is going good.

link to the challenge?
also we post code using the “”"

You’re misunderstanding what the challenge is and what an HTML entity is. Reread the description: as with all the algorithm questions, this is just asking you to write plain JavaScript. What you’ve written isn’t plain JS (it will only even run as intended in a browser when attached to an HTML page). It is asking to to write a function that takes a string and returns a different string.

1 Like