Tell us what’s happening:
I had a lot of trouble in figuring out what was wrong with this solution (but I solved it)… so I have a simple question: there is a way to have printed somewhere the raw html of a string?
Did that actually pass? When I run the code you posted,the replace(…) expressions are getting hung if there are more than one of a given character (for example, two <, it would catch the first). Instead, I had to use actual regex. For example, /\</g is the regex to find ALL instances of the < char and replace them.
As to your question, simply separate your function into three steps: first, save the results of replace(), perhaps to newStr. Second, console.info(...) or console.log(...) or whatever the value of newStr. Third, return that newStr value.
Right. So, going by what I suggested (saving the results of replace() to another string), you can easily print either str or newStr to the console, which will print as the string value (raw HTML and all).