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 Display the Value of a String on a Page

James Summers
James Summers
704 Points

getting an invalid syntax error

Whenever I run this code const stringToShout = prompt("What do you want to SHOUT?"); const shout = stringToShout.toUpperCase(); const shoutMessage = <h2>The message to shout is: ${shout}!!</h2>; document.querySelector('main'); console.log(shoutMessage).innerHTML = shoutMessage;

in a console I get this notifacation:

VM1597:1 Uncaught SyntaxError: Identifier 'stringToShout' has already been declared at <anonymous>:1:1

what is wrong? I followed Professor Guil's code exactly.

1 Answer

Steven Parker
Steven Parker
230,853 Points

The particular error message you saw doesn't seem to fit the code shown, but there is another obvious issue:

One video example shows the result using console.log, and another example outputs to the page by updating the innerHTML property of a selected element.

But you can't mix these, since console.log does not return an HTML element.

And for future questions, use Markdown formatting to preserve the code's appearance and retain special symbols.