Help me with This code please!

Hi,
I am a beginner in JavaScript. I am looking to apply for a course and I have some questions to attempt. Similar questions will be asked during the assessment. Please can anyone help me solve this? I know what headers are but as I am learning through a programme I haven’t learnt about this yet. Also I don’t have a lot of time and would like to understand this and move on to the nest question.

QUESTION
Let’s write a simple markdown parser function that will take in a single line of markdown and be translated into the appropriate HTML. To keep it simple, we’ll support only one feature of markdown in atx syntax: headers.

Headers are designated by (1-6) hashes followed by a space, followed by text. The number of hashes determines the header level of the HTML output.

ADDITIONAL RUES:

Additional Rules

Header content should only come after the initial hashtag(s) plus a space character.

Invalid headers should just be returned as the markdown that was recieved, no translation necessary.

Spaces before and after both the header content and the hashtag(s) should be ignored in the resulting output.

This is what I was given to work on it:

let assert = require("chai").assert;
describe('Markdown Headers', function() {
  it('basic_valid_cases', function() {
    assert.deepEqual(markdownParser("# header"), "<h1>header</h1>");
    assert.deepEqual(markdownParser("## smaller header"), "<h2>smaller header</h2>");
  });
  it('basic_invalid_cases', function() {
    assert.deepEqual(markdownParser("#Invalid"), "#Invalid");
  });
});

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://www.freecodecamp.org/learn.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

1 Like

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

thank you,
will have a look at the files first then.