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 Introducing the Practice

I am getting an "Uncaught SyntaxError: Unexpected identifier" in my code. It is in the var message... (not the heading)

Help?

alert("Let's do some math!");

var first = prompt("Please pick a number between 1 and 10"); var firstNumber = parseFloat(first);

var second = prompt("Please pick another number between 1 and 10"); var secondNumber = parseFloat(second);

var message = ("<h1>" + "Math with the numbers " + firstNumber + " and " + secondNumber +"</h1>") +"<br>";

var add = firstNumber + secondNumber; var subtract = firstNumber - secondNumbe; var multiply = firstNumber * secondNumber; var divide = firstNumber / secondNumber;

var message = (firstNumber + " + " secondNumber + " = " + add + "<br>" + firstNumber + " - " secondNumber + " = " + subtract + "<br>" + firstNumber + " * " secondNumber + " = " + multiply + "<br>" + firstNumber + " / " secondNumber + " = " + divide + "<br>");

document.write(message);

1 Answer

You are missing some + in your message variable! For example,

"<br>" + firstNumber + " - " secondNumber

After " - " there should be a + for concatenation before writing the secondNumber variable. You have a couple missing is all!

I hope that helps! Good luck with your coding!