Daily Coding Challenge - Markdown Italic Parser

Why this doesn’t work? Could someone help me?

function parseItalic(markdown) {
const re = /(?\S.*\S)|*(?\S.*\S)*/g;
return markdown.replace(re, “” + “$” + “”);
}

Your code so far

function parseItalic(markdown) {
  const re = /_(?<txt>\S.*\S)_|\*(?<txt>\S.*\S)\*/g;
  return markdown.replace(re, "<i>" + "$<txt>" + "</i>");
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

Challenge Information:

Daily Coding Challenge - Markdown Italic Parser

https://www.freecodecamp.org/learn/daily-coding-challenge/2025-12-31

Welcome to the forum @dan.floyd111

Try changing the function name to parseItalics

Happy coding

1 Like

Yes, there’s a bug in that challenge, as the seed code has the function name as parseItalic, instead of parseItalics.

CORRECTION: The function calls in the tests are not pluralising the function name.

If you pluralise both, you should pass most tests but you’re not coding correctly for the final test (which has multiple sets of italics).

1 Like

Your regular expression has errors. You can test it using this tool:

regex101: build, test, and debug regex

And please review this lecture about how to use replace() and match() to replace all occurrences of a pattern in a string:

Working with Regular Expressions - How Can You Match and Replace All Occurrences in a String? | Learn | freeCodeCamp.org

Thanks! Changed to “parseItalics” and it works, it was a bit confusing yes :smiley:
I spotted the issue on the reg-ex as well, I forgot to make it lazy
const re = /_(?<txt>\S.*?\S)_|\*(?<txt>\S.*?\S)\*/g;

1 Like