JavaScript JavaScript Basics Introducing JavaScript The Console Challenge Answer

Lotte Bloem
Lotte Bloem
18,627 Points

I still get a error, what am i doing wrong?

It says i miss the " " in line 2. And when i delete that hole line, it's still giving me that error!

alert("Help me fix this program!");
alert("Can you get this message to appear?");
document.write("<h2>My first JavaScript program</h2>");
document.write("<p>I'm practicing 'debugging'.</p>");
Bobby Verlaan
Bobby Verlaan
21,462 Points

Hehe. Creative brief! Could you please add your code as well? Then we can look into what the problem might be. Chances are you have missed the ; symbol on line 1.

3 Answers

Lotte Bloem
Lotte Bloem
18,627 Points

Hi Bobby, this is my first time that i use this forum. Can you please explain how i can add the code in here?

Konrad Pilch
Konrad Pilch
2,434 Points

A fast thingy I did for you is here your look beautiful as well.

Bobby Verlaan
Bobby Verlaan
21,462 Points

I see the end of the message wasn't the creative part, but the actual code you wrote that makes the error! With the markup added now I can read it :-). Looks like Nejc already got you covered! Escaping with \ should work. Keep in mind that double quotes and single quote can be used together as long as they are inside eachother:

  • " hello you're good " <-- good
  • ' hello you're good' <-- bad

To test Nejc advice. Create a .html file on your computer, edit it with notepad (or other texteditor), save your code in the document and open up the html in your own environment. As far as I can see that should work :-)

Konrad Pilch
Konrad Pilch
2,434 Points

There are few sublime text editors like sublimetext2/3 , brackets, coda, notepad++ and so on. I recommend to set the screen on black background, it will save your eyes in long term .

Nejc Vukovic
Nejc Vukovic
Full Stack JavaScript Techdegree Student 35,750 Points

Hi as you have written the code looks fine and I think the debugger is giving a false error:

//this is your line
document.write("I'm practicing 'debugging'."); 

//use this instead
document.write("I\'m practicing 'debugging'.");
//the ' should be escaped -> "I\'m ...

If I'm not mistaken then this could be a problem -> You have to look at it like this -> the ' in I'm opens a string literal and hte second ' at 'debugging closes it and then debugging' opens another string literal that isn't closed.

You should use an escape character for the ( I'm ) like I have written in the code above.

Try it and give some feedback.

Happy Coding!!!

Lotte Bloem
Lotte Bloem
18,627 Points

Ah tnx guys! it's works now!