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 trialSteven Good
2,303 PointsThe code in the video doesn't appear to work - uncaught syntax error and alert box not showing - any ideas?
function goToCoffeeShop(drink) { alert(drink + “ is on the way!”); } goToCoffeeShop(“Espresso”);
When I previewed this, nothing appeared. I checked the code in the console log and there is a syntax error on the 2nd line. I can't see any errors in the code, so I'm a little confused. Would anyone know how to fix this problem? Thanks
3 Answers
Erik Nuber
20,629 Pointsfunction goToCoffeeShop(drink) {
alert(drink + ' is on the way!');
}
goToCoffeeShop('Espresso');
It has to do with the quotation marks. I know it's an odd thing but the curly quotation marks won't work, they have to be " or '.
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsIt is odd. Syntax should be ok. If you dropped the } from the second line to the third?
Steven Good
2,303 PointsCheers guys. I didn't actually touch the code. It was already in the workspace. The alert box doesn't appear immediately when you preview it, but if you reload the page, the alert box appears.
Erik Nuber
20,629 PointsI copy and pasted your code and, just changed the quotation marks. With that it worked properly. You can copy and paste the snippet into the console and you will see it is fine.