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

Gabriela Miranda
Gabriela Miranda
185 Points

My code does not run. The only thing is showing is "What is your name". What did I wrong?

const name = prompt ("What is your name?"); let message= "Hello " + name + ". Welcome to my music site." message += "I am so happy you came by to visi,"; message += name; message += ".Feel gree to came again to listen to more music."; console.log(message);

And why is necessary console.log(message) in the end again?

2 Answers

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Hi @Gabriela Miranda you have a missing ; to terminate one of your statements to continue running the code properly. This is after declaring your message variable where you are assigning it's initial value.

Correction:

const name = prompt('What is your name?');

let message = 'Hello ' + name + '. Welcome to my music site.';
message += 'I am so happy you came by to visi,';
message += name;
message += '.Feel gree to came again to listen to more music.';
console.log(message);

The console.log statement isn't exactly "necessary" outside of the scope of the video, it's just so you can see what the value is and if that value is the correct result. Console logging in general allows you to debug your code to ensure you are getting the value you expect.

Gabriela Miranda
Gabriela Miranda
185 Points

Thanks @Jamie Reardon But still does not run after. Where is the missing ;? const name = prompt('What is your name?');

let message = 'Hello ' + name + '. Welcome to my music site.'; message += 'I am so happy you came by to visit,'; message += name; message += '.Feel free to came again to listen to more music.'; console.log(message);

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Hey Gabriela Miranda when adding code to your question, and what Steven Parker is referring to, is to use Markdown formatting into your post so that it is easy to read, it's difficult to understand code that isn't formatted properly. Below the text box you will see a reference to a Markdown Cheatsheet that will help you write out your posts on the forums.

As for your question, I already gave you the correct code above formatted that shows the missing ; statement terminator. This solution solves the issue, and it therefore looks like you are using it in your latest reply. The line that was missing the ; was your second statement that you used to declare the variable message which I have also pointed out in my answer.

There is no issue with this code so I am not sure what the issue is here? If you are still having issues please write your code in the suggested markdown format and describe the issue(s) you are facing.

Steven Parker
Steven Parker
229,644 Points

I'm guessing your code is actually on multiple lines, but it doesn't show that way because you didn't use Markdown formatting to preserve the code's appearance.

When you see "What is your name", it should be in a box that has a rectangle for you to use to answer the question. It should also have a button labeled "OK" to click on after you put in the answer.

Only after you use the button will you see the final result, but it will be shown in the console instead of the page. If you wanted to show it on the page instead, you could use "document.write" instead of "console.log".

Gabriela Miranda
Gabriela Miranda
185 Points

Steven Parker. I do not see where I did not use the Markdown. It is an instering method the use of "document.write". in my mind I did all the markdown formatting rightly, like the teacher.

Steven Parker
Steven Parker
229,644 Points

If you have not seen it already, watch this video about Markdown formatting (just click on the colored words to launch it). If you compare the code in your question to the code in Jamie's first post you can see the difference.