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 Introduction to Programming Basics Comments

Kevin Naegele
Kevin Naegele
10,868 Points

Java is not running in console

When I run my java script the console shows errors, and i do not get any prompts or logs besides 404. I am using chrome and i have tried on my computer and from a my web hosting

7 Answers

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Kevin Naegele

404 means file not found. Are you loading this JS from an external JS file? Then open the HTML page and make sure

  1. the path in the <script> tag is correct.
  2. You've correctly spelled the name of the JS file

For example:

<script src="myjava.js"></script>
Ana Gledovic
Ana Gledovic
7,465 Points

Hey Kevin,

Paste us some code to see what's wrong :D

Best, Ana

Kevin Naegele
Kevin Naegele
10,868 Points

Great idea!

console.log("Hello from myjave"); // this is not needed
console.log("BAM");

var name= prompt(, "What is your name");

alert("hello" + name);
Dave McFarland
Dave McFarland
Treehouse Teacher

Hi Kevin Naegele To put code into a forum post use triple back ticks -- ``` — around the code. I fixed your code here, but in the future here's a forum discussion that describes how to add HTML, CSS, JavaScript or other code to the forum: https://teamtreehouse.com/forum/posting-code-to-the-forum

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

The prompt() function requires 2 arguments -- the first is the question you want to ask and the second is text that appears INSIDE the text field the user types into. I usually just pass an empty string for this:

var name= prompt("What is your name", "");
Kevin Naegele
Kevin Naegele
10,868 Points

I changed it to only be

console.log("Hello from myjave.js"); // this is not needed
console.log("BAM");

still not showing and getting a 404

Kevin Naegele
Kevin Naegele
10,868 Points

I must of had an extra space in the code, but meow it is working great. :D