Tell us what’s happening:
My code works if I open the browser console, but the test doesn’t work. The built-in console doesn’t show the HTML tags, I understand that.
Your code so far
function convert(heading) {
const regex = /\s*#+\s+/;
if (regex.test(heading)) {
let numHash = heading.match("#+");
if (numHash[0].length <= 6) {
heading = heading.replace(regex, `<h${numHash[0].length}>`);
heading = heading + `<h${numHash[0].length}>`;
} else {
heading = "Invalid format";
}
console.log(heading);
} else {
heading = "Invalid format";
console.log(heading);
}
return heading;
}
convert("## My #2 heading");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Daily Coding Challenge - Markdown Heading Converter
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-11-19