Hi everyone,
I’m trying to solve the Convert HTML challenge but it gets stuck in a certain test, I have copied the test to try it and I think I get the required output, but still, it doesn’t get a checkmark.
Here is my code so far:
function convertHTML(str) {
let split = str.split("");
let replace = function (char,arr) {
let newStr;
let chars = ["&", "<", ">","\"","'"];
let name = ["&","<",">","&qout;","'"];
if(chars.includes(char)) {
arr.splice(arr.indexOf(char),1,name[chars.indexOf(char)]);
newStr = arr.join("");
return newStr;
} else {
newStr = split.join("");
return newStr;
}
}
let newString = split.map(x => replace(x,split));
console.log(newString[newString.length-1])
return newString[newString.length-1];
}
convertHTML('Stuff in "quotation marks"');
Thanks in advance.