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 Making Decisions in Your Code with Conditional Statements Introducing Conditional Statements

Spencer Renfro
PLUS
Spencer Renfro
Courses Plus Student 11,133 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
231,271 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
Courses Plus Student 11,133 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
231,271 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
PLUS
Spencer Renfro
Courses Plus Student 11,133 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
231,271 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
231,271 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
231,271 Points

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