Build a Markdown Previewer tests not passing

i seem to fail this project for days. it passes only the 3/8 from all requierments no matter what i write or 0 if i dont put the text with the heading 1, heading 2, and so on what i want to write in there to be seen in the textarea’s #editor.
html:

<div id="app">
 <div class="container">
    <h1>Markdown Previewer</h1>
    <div class="editor">
      <h2>Editor</h2>
      <label for="markdown">Enter your Markdown:</label>
  <textarea id="editor" name="markdown" placeholder=" type text here...">
    # Heading 1\n\n## Subheading\n\nHere is a [link](https://www.example.com).\n\nHere is some `inline code`.\n\n```js\n// This is a code block\nfunction example() {\n  console.log('Hello, world!');\n}\n```\n\n- List item 1\n- List item 2\n- List item 3\n\n> This is a blockquote.\n\n![Example image](https://via.placeholder.com/150 'Example image')\n\n**Bolded text**
     </textarea>
    </div>
    <div class="preview">
      <h2>Preview</h2>
      <div id="preview">
       
      </div>
    </div>
  </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/2.1.3/marked.min.js" integrity="sha512-5e5kjUc5F8CCBwM5udzXOi5pd3L0zQ+Tl1LJxV80z69mtdm76COW0q3TyhO9k24M5T5P7JmEGeN4UjRUwGQzHw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

js:


const editor = document.querySelector('#editor');
const preview = document.querySelector('#preview');


editor.addEventListener('input', () => {
  
  const markdown = editor.value;

  
  const html = marked(markdown);

  
  preview.innerHTML = html;
});
class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      markdown: `# Heading 1

## Subheading

Here is a [link](https://www.example.com).

Here is some \`inline code\`.

\`\`\`
// This is a code block
function example() {
  console.log('Hello, world!');
}
\`\`\`

- List item 1
- List item 2
- List item 3

> This is a blockquote.

![Example image](https://via.placeholder.com/150 "Example image")

**Bolded text**`
    };
    marked.setOptions({
      gfm: true,
      breaks: true
    });
    this.handleChange = this.handleChange.bind(this);
  }
  
  handleChange(event) {
    this.setState({
      markdown: event.target.value
    });
  }
  
  render() {
    return (
      <div>
        <Editor markdown={this.state.markdown} handleChange={this.handleChange} />
        <Previewer markdown={this.state.markdown} />
      </div>
    );
  }
}

im using codepen .tried to write a different react code …still not passing anything.i thought its my editor not working correctly,so i tried to check some other markdown code and copy them to see if they pass in my editor(the projects were ones that passed all 8 steps from thr respective users).its not working…now im here to ask for some help to pass this project.maybe my code after all its wrong .should i add something.to delete something maybe …help please

Please take some time and learn more about React. It is very hard to use a tool you haven’t properly learned how to use.

Also, for React I would highly recommend using StackBlitz or CodeSandbox.

thanks…ill check it .i would’ve liked if someone also could explain to me why even if i copy a code thats passing the tests , in my own editor its not passing? i did this with several projects and still doesnt want to work.i mean shouldve shown pass in my editor too if its done corectly from someone else…i do that so i can check myself if my code its similar\ corect to other working solutions…i hope my issue its understandable and i get it fixed.

ok …i wrote a code step by step from youtube.and did everything identical as the person in the video and my code doesnt show anything when i preview it.not even the editor empty or something. nothing.why? i could pass all the other projects,but this one no…i rewrote my code , rewrote 2 other codes that are passing from other people and for me stil nothing passes. 1/8 (the first step always passes about “you have to use html,css,react,javascript,etc”.).can somebody explain to me why for me nothing works for the markdown project? could it be because of the cdn’s?help please

Where are you running the code? We can’t help you if you do not show the code. Please post a live example on StackBlitz/CodeSandbox or wherever you have it now.

Just because you copied code doesn’t mean you set it up correctly or that you didn’t make any mistakes.


As an aside, you are not allowed to use the code you copied for the certificate projects. That is in violation of the Academic Honesty Policy.

1 Like

You didn’t add React and the JS setting on Codepen has to use Babel.

Setting > JS > JavaScript Preprocessor > Use the dropdown and select Babel

Setting > JS > Add External Scripts/Pens (or Add Packages) > Add React and ReactDOM

You need a single root element that you render to using ReactDOM


You are not using React correctly, I don’t care where you copied this from. It is not correct. Please go through the tutorial I posted.

ok. ill try give a few days and maybe i can find a solution after studying better. maybe im not focusing as much as i should on this .thanks.

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