Tell us what’s happening:
When I attempt to test my function, the output I get appears identical. Copying the strings from the tests (as displayed in my browser; i obviously can’t see the actual test) and using a strict ===
comparison yields true for each example.
…but my tests are failing. Idk if I’m just too tired to see it, but I can’t locate my mistake(s).
Your code so far
function convertHTML(str) {
const entityMap = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
'\'': ''',
}
// :)
return str
.split('')
.map((val) =>
/([&<>"'\\])/.test(val) ? entityMap[val] : val
)
.join('')
;
}
const logAll = (...args) => { args.map((val) => {
console.log(val);
return val;
})};
logAll(
convertHTML("Dolce & Gabbana")
,convertHTML("Hamburgers < Pizza < Tacos")
,convertHTML("Sixty > twelve")
,convertHTML('Stuff in "quotation marks"')
,convertHTML("Schindler's List")
,convertHTML("<>")
,convertHTML("abc")
);
console.log(convertHTML("Dolce & Gabbana") === 'Dolce & Gabbana');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36
.
Link to the challenge: