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 JavaScript Basics Working with Strings Combine Strings

Jessaly Sinchico
Jessaly Sinchico
909 Points

"Uncaught SyntaxError: Identifier 'message' has already been declared"

const name = prompt("What is your name?");
const message = "Hello " + name;

console.log(message);

I'm following the video instructions, but for some reason is telling me that there is a SyntaxError. Please help.

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,671 Points

Question updated with code formatting. Check out the Markdown Cheatsheet below the Add an Answer submission for syntax examples, or choose Edit Question from the three dots next to Add Comment to see how I improved the readability.

2 Answers

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

Jessaly Sinchico the current code you have in your question is valid. The error is specific in the context that it means that you are trying to redeclare a const variable, which you can't do. Double check the video's code line for line. Notice how the teacher changes the keyword const to let to allow reassignment.

Nicole Buckenwolf
Nicole Buckenwolf
8,718 Points

Just finish the video - he addresses this

Gabriela Miranda
Gabriela Miranda
202 Points

I fisished, though it still not working.

const name = prompt("whats is yor name");

let message = "Hello " + name;

conole.log(message);

The word "Hello" dos not apear.