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

Why my JavaScript it doesn't work? "prompt('Hello'); " this statement didn't appear the pop-up. Help me please..

Why my JavaScript it doesn't work? "prompt('Hello'); " this statement didn't appear the pop-up. Help me please.. I have no idea too.

3 Answers

Steven Parker
Steven Parker
243,228 Points

Were the quotes you have around the statement actually in the program? If so, that would have created a string literal instead of a program statement, and would explain why you did not see the prompt.

Also, when you call this function, you would normally want to catch the return value in a variable to use later. So a typical code line with this function might look like this:

var answer = prompt('Hello'); 

For future reference: when asking a question about something in a course, it can help to get a better answer if you include a link to the course page in your question. If the page has a "Get Help" button on it, you can use that to create a question and it will create a link for you, and also copy any code you were working with into the question.

@Steven Parker thank you for your answer. Here the link: https://teamtreehouse.com/workspaces/35002002 this link doesn't work.

Steven Parker
Steven Parker
243,228 Points

You can't share a direct URL to your workspace, it's temporary and only exists while you are using it.

But you can use the snapshot function in the workspace and provide the link to that.

Here is my project. @Steven Parker thank you for help me. https://github.com/senglongha/JavaScript/tree/master

Steven Parker
Steven Parker
243,228 Points

Wow that's a lot more code! Are you sure this is for the same question?

But anyway, the code in the repo seems to be missing a closing brace after line 36:

    wrong.push(question);
  }  // <-- add this brace

But for future issues, a workspace "snapshot" is much handier for analysis!

@Steven Parker thank you so much.. You're right..

This account will be disappear soon. It is a free trail account.. So, I would like to contact you on social media.

Steven Parker
Steven Parker
243,228 Points

I'm actually not a user of social media. But I'm glad i was able to help.

Happy coding!