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 trialKevin Naegele
10,868 PointsJava 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
Treehouse Teacher404 means file not found. Are you loading this JS from an external JS file? Then open the HTML page and make sure
- the path in the
<script>
tag is correct. - You've correctly spelled the name of the JS file
For example:
<script src="myjava.js"></script>
Ana Gledovic
7,465 PointsHey Kevin,
Paste us some code to see what's wrong :D
Best, Ana
Kevin Naegele
10,868 PointsGreat 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
Treehouse TeacherHi 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
Treehouse TeacherThe 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
10,868 PointsI 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
10,868 PointsThanks
Kevin Naegele
10,868 PointsI must of had an extra space in the code, but meow it is working great. :D