Tell us what’s happening:
This code works , but I don’t know why it causes a Reference in fCC’s editor
Your code so far
function convertHTML(str) {
const el = document.createElement('span');
el.textContent = str
return el.innerHTML
}
convertHTML("Dolce & Gabbana");
convertHTML("Hamburgers < Pizza < Tacos")
convertHTML("Sixty > twelve")
convertHTML("<>")
convertHTML("abc")
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
.
Challenge: Convert HTML Entities
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
eoja
October 2, 2020, 9:25pm
2
It means in the fcc editor apparently there is no document to access.
You need to write a function to replace the characters without getting the innerHTML of a dom element.
1 Like
Wow! The document
object can’t be accessed. Like to tell me more about it?
eoja
October 2, 2020, 10:03pm
4
I don’t know the inner workings of the fcc editor. But you don’t need to access the dom for this challenge. And although your code logs the expected string in a browser, it defeats the purpose of the challenge which is to write an algorithm that identifies certain characters in a string and replaces those characters with certain other characters.
1 Like