Bug at JSON APIs and AJAX: Convert JSON Data to HTML

My first attempt as a solution that should be valid but it’s not:

The solution is adding a space after calling the variable:

html += "<strong>" + key + "</strong>: "+ val[key] + "<br>";

Both solutions should be correct. Almost certain that is an error of regex.

I looked through the github repo and saw that this was the regex:

assert(code.match(/html\s+?(\+=|=\shtml\s\+)/g));

and the regex exp should be:

assert(code.match(/html\s*?(\+=|=\shtml\s\+)/g));

I’m not sure how to change the repo itself so I posted the issue here.

You are quite right. This is a small bug.

If you are looking to contribute, feel free to read: Contribute to the freeCodeCamp.org Community

I have opened an issue on the repo: Convert JSON Data to HTML regex typo · Issue #41133 · freeCodeCamp/freeCodeCamp (github.com)

Thank you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.