Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics Making Decisions in Your Code with Conditional Statements Introducing Conditional Statements

Spencer Renfro
Spencer Renfro
2,767 Points

Why am I getting a violation error inside the console?

I get this violation message to appear when I run my code.

jquery.js:3 [Violation] Added synchronous DOM mutation listener to a 'DOMNodeInserted' event. Consider using MutationObserver to make the page more responsive.

Here is my code: const answer = prompt('Which planet is closest to the sun?');

if (answer.toUpperCase() === 'MERCURY') { console.log("That's correct!") } else { console.log("Sorry, that's not correct.")

}

4 Answers

Steven Parker
Steven Parker
210,425 Points

Odd, I can't replicate the problem and this error message seems to come from "jQuery"; but that's not used in this code (and I don't think it's used anywhere in this entire course). If you're using a workspace, make a snapshot of your workspace and post the link to it here to allow a more accurate analysis.

if you're doing this in a different environment, see if you accidentally configured it to use jQuery.

Spencer Renfro
Spencer Renfro
2,767 Points

I used this in the treehouse environment only and used the development tools for mac (command option j) here is my link: https://w.trhou.se/n1ffpq5k4n

Steven Parker
Steven Parker
210,425 Points

I forked the snapshot, opened the preview, and it ran fine. I checked the entire project to confirm that there is no reference to jQuery, so I'm totally baffled by the message you are seeing.

Spencer Renfro
Spencer Renfro
2,767 Points

It runs the first time then I refresh and run it and that code pops up, but thank you for your input on this!

Steven Parker
Steven Parker
210,425 Points

I tried multiple refreshes and still no error. But as I said, since the project doesn't use jQuery it's not even a possible error you could get from this project.

I am having the same problem. This is the error I am getting "Uncaught SyntaxError: Unexpected token ';' conditionals.js:4 "

Steven Parker
Steven Parker
210,425 Points

That's a very different problem. You should start a fresh question and post a snapshot of your own workspace in it.

I did finally get it to work. I had to take the semicolons out for some reason and it worked.

Steven Parker
Steven Parker
210,425 Points

You could still create a new question and post the original code if you'd like to understand what was happening.