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

JavaScript

am 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

https://w.trhou.se/k9mndi6rck

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi! 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! :sparkles:

yes this works thank you

this 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 :sparkles: