Tell us what’s happening:
Hello, guys!
I already pass the challenge with replace, but where is an a mistake in my first version with switch statment i still can’t understand
Can someone to explain to me why the code can’t pass test cases?
I tried to rewrite code a bit few times, but it’s still not pass
However, for my opinion and tests the code make convert correctly
Your code so far
function convertHTML(str) {
let strArr = str.split('');
for (let i = 0; i < strArr.length; i++) {
switch(strArr[i]) {
case '&':
strArr[i] = '&';
break;
case '<':
strArr[i] = '<';
break;
case '>':
strArr[i] = '>';
break;
case '"':
strArr[i] = '"';
break;
case "'":
strArr[i] = ''';
break;
}
}
strArr = strArr.join('');
return strArr;
}
convertHTML("Dolce & Gabbana");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities