Convert HTML Entities Issue

Tell us what’s happening:
I am not understanding why this is not working

Your code so far

function convertHTML(str) {
let regEx = /[&<>""']/g

let newStr = str.replace(regEx, function(char){
	if(char === "&" ){
		return "&​amp;"
	} else if(char === ">"){
		return "&​gt;" 
	} else if(char === "<"){
		return "&​lt;" 
	} else if(char === '"'){
		return "&​quot;"
	} else if(char === "'"){
		return "&​apos;"
return newStr

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36.

Link to the challenge:

It is working (checked your results with the console). Seems to be something on fCC’s end?

Oh golly – is this ANOTHER semicolons thing? hahahaha

As it happens, it isn’t a semi-colon thing. Copy the code shown, and paste it into jsfiddle’s editor. You will notice an extra character between the & and amp;, or the & and whatever follows. Your keyboard is sticking an extra character in there.

In the jsfiddle editor, it shows up as a red dot between the ampersand and the chosen tag:



Thanks so much! It worked once I deleted the dots.

1 Like