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 Tiedemann
295 PointsMy make a story game. When I watched his solution I was waaayyyyyyy off. This is my only experience programming.
var noun = prompt("Please enter a noun");
var verb = prompt("Please enter a verb");
var adjective = prompt("Please enter an adjective");
var story = 'The ' + noun;
story += ' went to the store and was excited.'
story += 'When the ' + noun;
story += ' got home he ' + verb + ' on the tractor even though he was ' + adjective + '.';
document.write(story);
alert('You finished the game. I hope it was everything you expected and more!');
Pretty terrible right?
Edit: For some reason when I post this the code shows up in a paragraph format but I made it to have each var on its own line, each story += on its own line as well.
MOD note: added mark down to code to make it more readable.
2 Answers
Jacob Mishkin
23,118 PointsJustin, Your program is fine. It works! to post code in the forum please review the Markdown Cheatsheet right above the post comment button. It will tell you how to properly paste your code into your comment. So we can properly read your code.
The thing about programing is that there is no one way to do something. There are several ways to solve a problem, some are just better than others(best practice). I tested your code in codepen and it works great! think of it as a rough draft, now if you want take this code and see if you can further improve upon it throughout the course.
Jason Anders
Treehouse Moderator 145,860 PointsHey Justin, I see nothing wrong with your code. It does what it's supposed to do. Like Jacob said, there are many ways to achieve the same result. It all depends on how you want to do it. As long as it's understandable to you (if you were to look at it a year from now) and is relatively understandable to someone else. All is good.
Keep Coding! :)