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 trialJames Okrah
2,061 Pointspractice 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
5 Answers
Blayne Holland
19,321 PointsCould 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>";
document.write(message);
Boris Gronev
1,519 PointsI 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
36,305 PointsAnother way of doing things
This is not an answer for your work. I just thought I'd share another way of implementing the programme.
premnath p
Courses Plus Student 268 Pointsyou are adding another h1 tag inside a h1 tag. you need to close h1 tag some browser does not parse it
Michael Maitoza
3,805 PointsHi 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.
Ben Payne
1,464 PointsBen Payne
1,464 PointsHey James,
After
num2
you're missing an concatenation operator.