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
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsJavaScript Story Maker Challenge
Hi all, I'm currently learning JS and I finished the first portion and we were asked to create a Story Maker game that would ask the user to input some information that information is to be stored in a variable and then all the users input was to be combined with other strings to create a story/message. Then we had to print the story to the browser window.
Here is the code.
var noun = prompt('What is your name?/你叫什么名字');
var name = noun;
var verb = prompt('What are you doing?');
var action = verb;
var verb = prompt('Please enter a verb');
var nextAction = verb;
var adjective = prompt('Please type an adjective.');
var describe = adjective;
var chinese = prompt('Please type or copy a chinese character.')
var character = chinese;
var country = prompt('Please enter the name of a country.');
var place = country;
var time = prompt('Please enter a time(Day, Week, Month, Year, o\'clock).')
var when = time;
var nounThing = prompt('Please enter a noun.')
var personal = nounThing;
alert("You\'re all done. Ready for the answer?");
var story = name + ' is who you are ' + action + '.';
story += ' The world thinks you\'re ';
story += describe + '. ';
story += ' It seems like you\'re getting somewhere, but ';
story += name;
story += ' Still feels very confused. ';
story += nextAction.toUpperCase();
story += ' is what you do when you\'re '
story += describe + '. ';
story += chinese;
story += ' is the chinese character for ';
story += personal + '. ';
story += 'Being single allows for a lot of traveling to ';
story += place + '. ';
story += when;
story += ' is an extremely awful time for ';
story += action;
story += ' This is the end of the story.';
document.write(story);
console.log(story);
console.log(story.length);
2 Answers
Dan Weru
48,030 PointsHi, great work. You code runs great. Are you looking for some help?
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsI appreciate that. What I'm looking for or would like to see is another way. That will help me think of different ways to go about achieving the same task. Anyways, thanks so much for taking the time to reply man. Really appreciate it and thanks for the advice. This really is a great community at Treehouse.
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsSAMUEL LAWRENCE
Courses Plus Student 8,447 PointsJavaScript is a very confusing language to me, it would be nice if you could provide another way or a simpler way you would have done this challenge, or a more effective way?
Dan Weru
48,030 PointsDan Weru
48,030 PointsYou’re just getting started. You’ll get the gist of it if you keep at it. There are certainly other ways of achieving the same task. That said, what you’re doing now is foundational.