Daily Coding Challenge - HTML Content Extractor

Tell us what’s happening:

My function does return the plain text content with all tags removed, but all the tests failed. :anguished_face:

Your code so far

function extractContent(html) {
  const removeRegex = /\<\>/gi
  return `"${html.replaceAll(removeRegex, "")}"`;
}

console.log(extractContent('<p>hello world</p>')) //returns "hello world"
console.log(extractContent('<p>hello <span>world</span></p>')) //returns "hello world"
console.log(extractContent('<a href="example.com">Click me</a>')) //returns "Click me"
console.log(extractContent('<p><button onClick="learnToCode()">Learn</button> to <code>code<code> <br/>for <strong>free</strong> <br/>on <a href="https://freecodecamp.org/" target="_blank"><span class="highlight">freecodecamp</span>.org</a>')) //returns "Learn to code for free on freecodecamp.org"
console.log(extractContent('<div class="container"><h1 id="title">Welcome to <strong>My</strong> Website.</h1><p>This is a <a href="https://example.com" target="_blank">link</a> to something <em>really</em> <span class="highlight">important</span>.</p><ul><li>Item <strong>one</strong></li><li>Item <em>two</em></li><li>Item three</li></ul><img src="pic.jpg" alt="A picture"/><p class="footer">Contact us at <a href="mailto:hello@example.com">hello@example.com</a> for <span>more <strong>info</strong></span>.</p></div>')) //returns "Welcome to My Website.This is a link to something really important.Item oneItem twoItem threeContact us at hello@example.com for more info."

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0

Challenge Information:

Daily Coding Challenge - HTML Content Extractor

https://www.freecodecamp.org/learn/daily-coding-challenge/2026-06-12

GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/daily-coding-challenge/6a0dcd03ee4e68698080ef6a.md

should the plain text include quotes?

Hi @Jayden1,

Try testing your regular expression at regex101: build, test, and debug regex.

Also, html is already a string, so you don’t need to do anything to “make” it a string.

Happy coding

The tests initially failed when there were no quotes, so I added quotes as I thought the expected output was meant to include quotes.

Thank you for sharing the link. I knew something wasn’t right when my code was so short, but it still gave a seemingly expected output anyway. It turns out I have to include a few more characters in my regex.