Tell us what’s happening:
Describe your issue in detail here.
Not sure what the problem is here. Every test is passing except for the "Stuff in “quotation marks” test…but the console is printing the string it is supposed to print.
Your code so far
function convertHTML(str) {
// create a variable initialized to the string split into an array
let strArr = str.split('');
//return the array mapped to the conditional chain: if the element is equal to the pattern, return a changed pattern based on the pattern found, else just return the element, then join it back into a string in a chained function
return strArr.map(element => {
if (element === '&') {
return element = '&';
} else if (element === '<') {
return element = '<';
} else if (element === '>') {
return element = '>';
} else if (element.match(/[\"]/)) {
return element = '&qout;';
} else if (element.match(/[\']/)) {
return element = ''';
} else {
return element
}
}).join('');
}
console.log(convertHTML("Dolce & Gabbana"));
console.log(convertHTML("Hamburgers < Pizza < Tacos"));
console.log(convertHTML("Sixty > twelve"));
console.log(convertHTML('Stuff in "quotation marks"'));
console.log(convertHTML("Schindler's List"));
console.log(convertHTML("<>"));
console.log(convertHTML("abc"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0
Challenge: Intermediate Algorithm Scripting - Convert HTML Entities
Link to the challenge: