I used this code to solve this challenge and it passes all the tests except the last. This is probably a bug, since I logged the return value from the console and “abc” (quotes included) is correctly logged.
Please correct me if I am doing something wrong. Thanks.
Your code so far
function convertHTML(str) {
let newStr='';
for(let s of str){
switch(s){
case '&':
newStr+='&';
break;
case '<':
newStr+='<';
break;
case '>':
newStr+='>';
break;
case '"':
newStr+='"';
break;
case '\'':
newStr+=''';
break;
default:
newStr+=s;
break;
}
}
return '"'+newStr+'"';
}
convertHTML("abc");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36
.
Challenge: Convert HTML Entities
Link to the challenge: