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 trialJustin Klebieko
283 PointsWhen I try to run my code it's not fully working. The code is absolutely correct. That isn't the problem.
When I try to run my code it's not fully working. The code is absolutely correct. That isn't the problem. Is it my browser? What's going on?
miikis
44,957 PointsWhat are you trying to run your code in? A browser? Which one? Workspaces? A Challenge? Which Challenge? In short, what does "it's not fully working" entail exactly?
8 Answers
miikis
44,957 PointsHey Justin,
Have you made sure that you're saving your files before loading the preview? If so, try clearing your cache and re-loading. Let me know if that works for you.
Liam English
3,837 PointsHi,
I've noticed a couple of things, which will hopefully help:
You are missing +questionsLeft at the end of each of your prompts:
var adjective = prompt('Please type an adjective' + questionsLeft);
Also, you are missing questions -=1; just after the noun prompt:
var questionsLeft = ' [' + questions + ' questions left]';
var noun = prompt('Please type a noun' + questionsLeft);
questions -= 1;
Justin Klebieko
283 PointsDefinately
var questions = 3;
var questionsLeft = ' [' + questions + ' questions left]';
var adjective = prompt('Please type an adjective');
questions -= 1;
questionsLeft = ' [' + questions + ' questions left]';
var verb = prompt('Please type a verb');
questions -= 1;
questionsLeft = ' [' + questions + ' questions left]';
var noun = prompt('Please type a noun');
alert('All done. Ready for the message?');
var sentence = "<h2>There once was a " + adjective;
sentence += ' programmer who wanted to use JavaScript to ' + verb;
sentence += ' the ' + noun + '.</h2>';
document.write(sentence);
Justin Klebieko
283 PointsIt will just ask me to input the adjective, verb and noun but then doesn't post anything to the screen.
Justin Klebieko
283 PointsI wonder if it's a virus. When I go to google and do a search I get redirected to a Yahoo search.
Alexander Davison
65,469 PointsHmmm.... I don't know, your code works fine for me. Hope it's not a virus
Justin Klebieko
283 PointsI am doing it in the workspace. It will just ask me to type a verb, noun and adjective then doesn't post anything to the screen. Should I use an IDE instead? Is there a problem with my HTML link?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>The Story Maker</title> </head> <body> <div class="container"> <h1>The Story Maker</h1> <script src="story.js"></script> </div> </body> </html>
nico dev
20,364 PointsThe code seems perfect and works just fine for me here.
Just an idea, why don't you try to add a console.log(sentence);
before and after the document.write
and open your console with CTRL + SHIFT + j (are you in Windows/Chrome? If MAC, Cmd instead of CTRL).
Do the console.log give you the sentence value you're expecting? In both cases? If so, it doesn't write the sentence in the browser? If so, do you have another browser?
Another thing you can try and sometimes help is closing the Workspaces and reopening it again (or even deleting cookies and that stuff).
HTH.
Jacob Mishkin
23,118 PointsThe workspace is working fine but, one of the variables in the project files is not defined. figure out which one, by using the devTools and fix the mistake. if you added the code above it works, but what browser are you using?
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsThere's probably something wrong with your code. Some mistakes are very hard to spot as a beginner.
Can you show your code?