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
shane smith
5,247 Pointsam i over thinking this or not enough?
am i over thinking this or not enough? trying to get user in put then call the function to get the final result in alert dialog box?? Dave McFarland
3 Answers
Jennifer Nordell
Treehouse TeacherHi! Well, I'm not Dave, but you have a couple of problems here. First, you're calling the function which takes two parameters, but you're not sending anything. But it wouldn't matter anyway because you immediately would be overwriting them with the prompt to the user. You're trying to return two strings concatenated together. If I had been the user and entered "coffee" and then "danish". Your code would return "coffeedanish". Also, drink and pastry are local to the function. They don't exist outside the scope of the function. I reworked your code a bit so that it functions like I think you're intending.
function goToCoffeeShop() {
var drink = prompt('what would you like to drink from coffee shop?');
var pastry = prompt('what pastry would you like from coffee shop?');
alert('Your ' + drink + ' and ' + pastry + ' are on the way.');
}
goToCoffeeShop();
Hope this helps!
shane smith
5,247 Pointsyes this works thank you
shane smith
5,247 Pointsthis is exactly what i wanted to do as i can run the function as many times as i want and get the same prompt. you are a
Jennifer Nordell
Treehouse Teachershane smith you're welcome!
Dave McFarland
Treehouse TeacherDave McFarland
Treehouse TeacherWell, I am Dave :) but I couldn't have answered any better than Jennifer Nordell!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherDave McFarland wow! What a compliment! Thanks