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 trialMegan Oliver
Front End Web Development Techdegree Graduate 20,985 PointsJava Script not working with Chrome.
I've been working through the Java Script Basics lessons and all was going well until the last 2 lessons. When I hit preview, my code doesn't do anything. I've double and triple checked that I've typed just what the teacher did and I'm pretty sure it's correct. I even tried typing in "document.write ("test"); on the first line and still nothing shows up in the preview. Anyone know what I'm doing wrong?
4 Answers
Brian Romine
9,518 PointsIf we could see your code, it would be really helpful. Something as simple as a misplaced semicolon or bracket can cause JS to just not run.
Though first, I would say that you should try refreshing your page. That sometimes does the trick.
Megan Oliver
Front End Web Development Techdegree Graduate 20,985 PointsHere's the code I have, right off the video. I've tried refreshing and that doesn't work.
var answer = prompt("What programming language is the name of a gem?"); if ( answer === 'Ruby' ) { document.write ("<p>That's right!</p>); }
Again, the prompt screen never shows up. And JavaScript is turned on on my browser.
Ira Bradley
12,976 PointsMegan -
I noticed in the code you posted that you are missing a closing parenthesis in your "That's right!" statement. I'm not sure this is the problem. Can you try the following. Open up the javascript console in chrome. (Usually either shift+command+J
pr shift+control+J
). At the console prompt type in or paste your first line of code
var answer = prompt("What programming language is the name of a gem?");
Then if the prompt pops up enter Ruby and press return. They type console.log(answer)
. This should print "Ruby" to the console. See attachment:
http://screencast.com/t/mQ9HChMZFxTy
If this all works then chrome isn't the issue. Do you have something running which prevents popups?
Megan Oliver
Front End Web Development Techdegree Graduate 20,985 PointsJust tried and the first line works in the console, the prompt box showed up and everything. Pop-ups aren't blocked, that was one of the first things I looked into.
I tried just putting the first line of code into workspaces and it doesn't work still, even though it works in the console.
Ira Bradley
12,976 PointsThere is nothing wrong with the code and chrome seems to be working. I'm assuming you've had workspaces working before. The only thing I can think to try is maybe another browser. Firefox is a good option. If you still can't get it to work I would contact support directly.
Megan Oliver
Front End Web Development Techdegree Graduate 20,985 PointsYes, I've been using Workspaces for a couple months with no problems until the last 2 lessons. Thank you for double checking my work, I was thinking it is a technical problem also. I'll contact support.
Ira Bradley
12,976 PointsIra Bradley
12,976 PointsI would recommend trying to refresh the browser and see if that restores your preview. If not please paste your code here. Often times it's something simple but easily overlooked.