Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Boolean Values

William Forbes
William Forbes
21,469 Points

P tags not working

My <p></p> are not working, I keep getting the error "expected )". Also can't the P tags be put in the HTML anyway? TY!

6 Answers

Thats a syntax error, you're probably missing a ")" somewhere . post your code I'll tell you where it is, or check the line number in your browser developer tools

Try this:

  document.write(" You are wrong!! The number was " + randomNumber + ".");
William Forbes
William Forbes
21,469 Points

Thanks for the quick reply!!! Below is my code I can't seem to find the error that's why I posted. Its saying the errors are on the document.write lines. var correctGuess = false; var randomNumber = Math.floor(Math.random() * 6) + 1; var guess = prompt('I am thinking of a number between 1 and 6, can you guess it?'); if (parseInt(guess) === randomNumber) { correctGuess = true; } if (correctGuess) { document.write("<p>You are right!</p>"); } else { document.write("<p> You are wrong!!"+ ' The number was ' + randomNumber + ".</p>"); }

William Forbes
William Forbes
21,469 Points

Thanks that worked, appreciate the quick response.! Do you know why we he is putting the <p> tages in the javascript and not using them on the HTML?

I'm glad it worked. It doesnt really matter if you put the tags in the HTML or via Javascript, it makes no difference :)

Leandro Severino
Leandro Severino
12,674 Points

For testing code purposes, tags doesn't really matter if you just need to know the data. The main purpose of tags is to tell the browser how to display the content.

For me, I still add the paragraph tag because Inserting it starts the text on the next line making it more readable if you have multiple contents on a single page. You can check document.writeln() too.