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
marcus shipman
8,686 PointsIs this code ok?
I use a different path than the instructor and got somewhat the same results. Is this correct or should I have written a code the same as the instructor?
alert("Are you ready to begin");
var word =prompt("Type in a word");
var verb = prompt("Type in a verb");
var adjective =prompt("Type in a adjective");
var total = word + verb + adjective + " he is really Good!!!!";
document.write(total);
alert ("Thankyou");
2 Answers
Chyno Deluxe
16,936 PointsYou'll want to add empty strings in between each variable so that the words a user enters is spaced correctly.
Your original code will output the following
//Output: Wordverbadjective he is really Good!!!!
changing your code to this will output it correctly
var total = word + " " + verb + " " + " " + adjective + " he is really Good!!!!";
//Output: Word verb adjective he is really Good!!!!
jsFiddle I hope this helps.
marcus shipman
8,686 PointsThanks jsFiddle, I have not gone over that part of the code yet in the training for spacing, but I kept wondering how it could have been done. Thanks for the info.