Text as Data
Text as Data
When text comes from a user, a database, or an API, your code should treat it as text unless you deliberately want markup. innerHTML asks the browser to parse the string as HTML. textContent writes the string exactly as text.
That distinction matters in comments, profile fields, chat previews, and search results. A learner often reaches for the property that seems to "put content inside the element" without asking whether the content should be parsed.
Your task: Fix the preview update so the submitted message is shown literally. The preview should display the angle brackets as characters and should not create a strong element.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
Text as Data
When text comes from a user, a database, or an API, your code should treat it as text unless you deliberately want markup. innerHTML asks the browser to parse the string as HTML. textContent writes the string exactly as text.
That distinction matters in comments, profile fields, chat previews, and search results. A learner often reaches for the property that seems to "put content inside the element" without asking whether the content should be parsed.
Your task: Fix the preview update so the submitted message is shown literally. The preview should display the angle brackets as characters and should not create a strong element.