Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript The Solution

practice java script math methods

i tried testing my code before continuing, what i realized was that, it runs perfectly. but after i add the var message = "<h1>maths with numbers " + num1 + " and "+ num2 "<h1>"; document.write(message); it doesnt run anymore. when i take it out , then it begins to run

Hey James,

After num2 you're missing an concatenation operator.

5 Answers

Blayne Holland
Blayne Holland
18,817 Points

Could be a syntax error. I noticed between num2 and <h1> there is no concatenation operator. Add a + in there and you should be good.

var message = "<h1>maths with numbers " + num1 + " and "+ num2 + "<h1>"; 

I believe that Blayne Holland answer you correctly and just want to point you something - use the web browser console to found out where is the error. ;-)

Sam Donald
Sam Donald
36,305 Points

Another way of doing things

This is not an answer for your work. I just thought I'd share another way of implementing the programme.

you are adding another h1 tag inside a h1 tag. you need to close h1 tag some browser does not parse it

Michael Maitoza
Michael Maitoza
3,805 Points

Hi James, I think the issue lies in two places. Here is your code: var message = "<h1>maths with numbers " + num1 + " and "+ num2 "<h1>"; document.write(message); try looking after "num2" and also look at your closing <h1> tag. I believe you'll see that there are two things missing. I made similar mistakes in this very program. It is easy to overlook something like this and see the program not work.